How to query results for post_title and Custom Post Type/ACF field pivot query

I have a custom query that needs to match a search term to a custom post type of event by post title and by an ACF field host and then filters out events that have passed the current date to a REST API endpoint.

Theoretically, what I have in the function being passed to posts_where is working correctly, but with the addition of the secondary $where concatenation querying for a events that match the host that contains the search term, events are not being filtered anymore by relative date and past events are being returned, upcoming events are showing up in past events, etc.

To complicate the issue, the ACF field is not textual, it is a Post Object that references back to another custom post type, host.

the code:

<?php 
    // it add filter based by term (set as 'seach_term' in $wp_query)
    function search_filter($where, $wp_query){
        global $wpdb;
        if ( $search_term = $wp_query->get( 'search_term' ) ) {
          $esc_search_term = esc_sql( like_escape( $search_term ) );
          $where .= " AND {$wpdb->posts}.post_title like '%{$esc_search_term}%' AND {$wpdb->posts}.post_type='event'";
          $where .= " OR ID IN (SELECT {$wpdb->postmeta}.post_id FROM {$wpdb->postmeta} JOIN {$wpdb->posts} ON {$wpdb->postmeta}.meta_value= {$wpdb->posts}.ID WHERE {$wpdb->postmeta}.meta_key='event_hosts_0_host' AND {$wpdb->posts}.post_type='host' AND {$wpdb->posts}.post_title LIKE '%{$esc_search_term}%')";
        }
        return $where;
    }

    function get_events_by_filter_cb($request){
        $params = $request->get_params();
        $topPicks = $params('topevents') === 'true';
        $freeEvents = $params('free') === 'true';
        $channels = $params('channels');
        $search_term = $params('term');
        $offset = isset($params('offset')) ? intval($params('offset')) : 0;
        $per_page = isset($params('per_page')) ? intval($params('per_page')) : 15;
        $endsBy = isset($params('ends_by')) && $params('ends_by') !== '' ? intval($params('ends_by')) : NULL;
        $startsBy = isset($params('starts_by')) && $params('starts_by') !== '' ? intval($params('starts_by')) : NULL;
        $sort = isset($params('sort')) ? $params('sort') : NULL;

        $terms = explode(",", $channels);

        $args = array( 
            'post_type' => 'event',
            'posts_per_page' => $per_page,
            'post_status' => 'publish',
            'offset' => $offset,
            's' => $search_term,
            'meta_query' => array(
                'relation' => 'AND',
            ),
              'orderby' => array(
                array (
                'meta_key' => 'event_end_timestamp',
                'event_end_timestamp' => 'ASC',
                ),
                'title' => 'ASC',
            ),
        );

        // if search_term is defined and its not an empty string, add the search_term to the query
        if($search_term && $search_term != '') {
          $args('search_term') = $search_term;
        }

        // if topPicks flag is defined and TRUE, add the cornerstone flag to the meta-query
        if($topPicks) {
          $args('meta_query')('cornerstore') = array(
            'key' => 'cornerstone',
            'value' => '1',
                  'compare' => '=='
          );
        }

        if($freeEvents) {
          $args('meta_query')('free_event') = array(
              'key' => 'free_event',
              'value' => '1',
                    'compare' => '=='
          );
        }

        // if endsBy flag is defined and > 0, add the event_end_timestamp flag to the meta-query
        if ($endsBy && $endsBy > 0) {
            $args('meta_query')('event_end_timestamp') = array(
                'key' => 'event_end_timestamp',
                'type' => 'NUMERIC',
                'value'   => $endsBy,
                'compare' => '<',
            );
        }

        if ($startsBy && $startsBy > 0) {
            $args('meta_query')('event_start_timestamp') = array(
                'key' => 'event_end_timestamp',
                'type' => 'NUMERIC',
                'value'   => $startsBy,
                'compare' => '>=',
            );
        }

        // if terms flag is defined and its lenght > 0, add the channel taxonomy to the query
        if (sizeof($terms) != 0 && $channels != '') {
            $tax_query = array(
                array(
                    'taxonomy' => 'channels',
                    'field' => 'term_id',
                    'terms' => $terms,
                    'hide_empty' => true,
                    'parent'   => 0,
                )
            );
            $args('tax_query') = $tax_query;
        }

        if(isset($sort)) {
            if($sort === 'oldest-first') {
                $args('orderby') = array(
                    'event_end_timestamp' => 'DESC',
                    'title' => 'ASC',
                );
            }

            if($sort === 'title-asc') {
                $args('orderby') = array(
                    'title' => 'ASC',
                );
            }

            if($sort === 'title-desc') {
                $args('orderby') = array(
                    'title' => 'DESC',
                );
            }

            if($sort === 'newest') {
                $args('orderby') = 'publish_date';
                $args('order') = 'DESC';
            }
        }

        // adds a filter to match the title
        add_filter( 'posts_where', 'search_filter', 10, 2 );

        $query = new WP_Query($args);
        $events_count = $query ->found_posts;

        // remove the filter
        remove_filter( 'posts_where', 'search_filter', 10, 2 );

        $headers = $request->get_headers();
        $headers('x-wp-total') = $events_count;
        $body = ();

        if ( $query->have_posts() ) {
            while ( $query->have_posts() ) {
                $query->the_post();
                $res = get_post();
                $res->acf = get_fields();
                $res->post_thumbnail = get_the_post_thumbnail_url($res->ID);
                $res->meta = array(
                    'end_timestamp' => get_post_meta($res->ID, 'event_end_timestamp', true),
                    // 'query' => $args,
                    // 'query_time' => time(),
                );
                array_push($body, $res);
            }
        }

        // var_dump($query->request);

        $response = new WP_REST_Response($body);
        $response->set_headers($headers);
        wp_reset_postdata();

        return $response;
    }

    add_action('rest_api_init', function () {
          register_rest_route( 'wp/v2', '/search/', array(
            'methods' => 'GET',
            'callback' => 'get_events_by_filter_cb',
          ) );
        }
    );