wp_update_post is not updating category

I figured it out! Apparently categories are no longer part of the database table for posts and are instead stored elsewhere. Therefore using the wp_insert_post has no way of setting a category.

I had to use wp_set_post_terms in order to set the categories which worked to automatically set both the parent and the child at the same time upon publishing.

wp_update_post doesn’t seem to mess with the categories, so there’s no need to pass them there.

Here is the part of the now working function:

$category=get_the_category ($post_id);
    $categories=array ('89', $category[0]->cat_ID);

    //Publish or unpublish post
        if ('draft' == get_post_status ($post_id)) {
            $post = get_post($post_id,ARRAY_A);
            $post['post_status'] ='publish';
            wp_insert_post($post);
            wp_set_post_terms( $post_id, $categories, 'category' );
            }


        else if ('publish' == get_post_status ($post_id)) {
            $post = get_post($post_id,ARRAY_A);
            $post['post_status'] ='draft'; 
            wp_update_post($post);
            }

I hope this is helpful to someone!