category A + category B Filter Combination

Implement a filter combination for products categorized under Category A and Category B.

add_filter('advanced_woo_discount_rules_filter_passed', function($filter_passed, $rule, $product, $sale_badge){
    //'array(1,2)' - give rule id as you needed
    if(in_array($rule->getId(),array(1,2)) && class_exists('\Wdr\App\Helpers\Woocommerce')){
        $rule_filter = $rule->getFilter();
        $categories = \Wdr\App\Helpers\Woocommerce::getProductCategories($product);
        $first_category_id = array();
        $second_category_id = array();
        if($rule_filter){
            foreach($rule_filter as $filter){
                $type = isset($filter->type) ? $filter->type : '';
                if( $filter->method == 'in_list'){
                    if($type == 'product_category'){
                        if(empty($first_category_id)){
                            $first_category_id = isset($filter->value) ? $filter->value : array();
                        }else if(empty($second_category_id)){
                            $second_category_id = isset($filter->value) ? $filter->value : array();
                        }
                    }
                }
            }
        }

        if(!empty($first_category_id) && !empty($second_category_id) ){
            $is_product_in_category = count(array_intersect($categories, $first_category_id)) > 0;
            if($is_product_in_category){
                $is_product_in_category = count(array_intersect($categories, $second_category_id)) > 0;
                if($is_product_in_category){
                    return true;
                }
                return false;
            }else{
                return false;
            }
        }
    }
    return $filter_passed;
}, 10, 4);