Custom tax_query filter not working for Woocommerce product categories

I figured out what the issue was. The page was displaying categories/subcategories and not the items themselves. This meant that woocommerce_product_subcategories() was the one filtering and that uses a different hook.

Here is what I added to my functions.php file.

add_filter( 'get_terms', 'get_subcategory_terms', 10, 3 );

function get_subcategory_terms( $terms, $taxonomies, $args ) {

  $new_terms = array();

  // if a product category and on the shop page
  if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() && is_shop() && isset($_SESSION['mid'])  ) {

    foreach ( $terms as $key => $term ) {

      if ( in_array( $term->slug, array( $_SESSION['mid'] ) ) ) {
        $new_terms[] = $term;
      }

    }

    $terms = $new_terms;
  }

  return $terms;
}