Include posts from feature category in pre_get_posts

I haven’t run this code so there may be a syntax error, but the gist is to return userfeed-taxonomy with the terms specified that have featured category OR cities-taxonomy with the terms specified and featured category OR anything else that’s not those taxonomies. It’s kind of clunky, maybe there is a better way:

    $query->set( 'tax_query', array(
        'relation' => 'OR',
        array(
            array(
                'relation' => 'AND',
                array(
                    'taxonomy' => 'userfeed-taxonomy',
                    'field' => 'id',
                    'terms' => $terms1
                ),
                array(
                    'taxonomy' => 'category',
                    'field' => 'slug',
                    'terms' => array( 'featured' )
                ),
            ),
        ),
        array(
            array(
                'relation' => 'AND',
                array(
                    'taxonomy' => 'cities-taxonomy',
                    'field' => 'id',
                    'terms' => $terms2
                ),
                array(
                    'taxonomy' => 'category',
                    'field' => 'slug',
                    'terms' => array( 'featured' )
                ),
            ),
        ),
        array(
            'relation' => 'AND',
            array(
                'taxonomy' => 'userfeed-taxonomy',
                'field' => 'id',
                'terms' => $terms1,
                'operator' => 'NOT IN'
            ),
            array(
                'taxonomy' => 'cities-taxonomy',
                'field' => 'id',
                'terms' => $terms2,
                'operator' => 'NOT IN'
            )
        )
    ) );