I'm not sure this will fix it, but maybe try using the current category slug for the $current_category variable, instead of single_cat_title(), like so:
$term = get_queried_object();
$current_category = $term->slug;
This might help because the category_name parameter in WP_Query, despite its name, should be the term slug. single_cat_title() ...
OK finally found the solution.
After looking in wp_term_taxonomy table, I noticed that taxonomy column describes the taxonomy term for tags - which is actually post_tag, not just 'tag'.
So, this works:
add_filter('rest_prepare_post_tag', 'wp_api_encode_yoast', 10, 3);
Hopefully someone will be helped by this.
From this support thread it seems like currently, Twitter should pick up the fallback image defined under SEO > Social > Facebook. There is no dedicated setting for Twitter at this point but other users are asking for it as well. So, it seems like right now your options are to try out the Facebook default image or set Twitter images on a per-page basis.
I found this and it works. Shout out to WP Munchies! https://wpmunchies.com/display-primary-category-using-yoasts-make-primary-feature/
// Fill in your custom taxonomy here
$yourTaxonomy = 'CUSTOM_TAXONOMY';
// SHOW YOAST PRIMARY CATEGORY, OR FIRST CATEGORY
$category = get_the_terms( $postId, $yourTaxonomy );
$useCatLink = true;
// If post has a ...