Contextually filtering a view using values from a completely separate table?
Make sure you check mark allow multiple values on your contextual filter's &quot;More&quot; settings.

Use hook_views_pre_view to pass your uid's to the arguments (contextual filter).
/*
 * Implements hook_views_pre_view()
 */
function mymodule_views_pre_view(\Drupal\views\ViewExecutable $view, $display_id, array &amp;$args) {

  if ($view-&gt;id() == &quot;view_name&quot; &amp;&amp; $view-&gt;current_display == 'page_1') {
    $uids = [2, 19]; // hard coded example, you would query db here.
    if (is_array($uids)) {
      $uids = implode('+', $uids);
    } 
    $args[0] = $uids;
  }

}

You will also need to disable the view's caching or add a cache tag if you created one for your other table query.