Searching all groups when adding approval, very slow with a large amount of groups

Summary

From an E2E test: #424474 (comment 1559521227) running against pre.gitlab.com When a user has a large amount of groups (in this case ~1700), searching for a group when adding an approval rule to an MR is very slow/unresponsive.

Steps to reproduce

  1. Log in as a user with access to 1700 groups
  2. Create an MR
  3. Add an approval rule
  4. Search for a group

What is the current bug behavior?

Screen_Recording_2023-09-14_at_16.42.08

What is the expected correct behavior?

Faster search result

Possible fixes