facetwp multiple parents

<?php

add_filter( 'facetwp_index_row', function( $params, $class ) {
	if ( 'sub_categories' == $params['facet_name'] ) { // change sub_categories to name of your facet
		$parents = array( 18, 20 ); // change to ids of your parent terms
		if ( ! isset( $params['parent_id'] ) || ! in_array( $params['parent_id'], $parents ) ) {
			$params['facet_value'] = ''; // skip indexing
		}
	}
	return $params;
}, 10, 2 );