Get categories from save_post hook

After doing much more search… it looks like the save_post hook does not run after the post categories are updated so it will only show the categories that the post had before the update (or no categories for new posts).

I found that I need to use this hook and then everything inside my function is updated:

add_action('rest_after_insert_post', 'test' , 10, 2 );

I had no idea that was the hook I needed to use. I hope this helps someone!