Having trouble with settings terms as array in pre_get_posts

You need to modify the tax_query block of code like below-

$q->set( 'tax_query', array(array(
    'taxonomy' => 'product_cat',
    'field' => 'term_id', // Here it would be 'term_id' instead of only 'ID'.
    'terms' => $allowedCats,
    'operator' => 'IN' // May be it would be 'IN' in stead of 'NOT IN'. Cause you are passing allowed product categories.
)));

Hope that helps.