The filter "approver" does not meet expectations when searching MR
<!--IssueSummary start-->
<details>
<summary>
Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards.
</summary>
- [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=512635)
</details>
<!--IssueSummary end-->
<!---
Please read this!
Before opening a new issue, make sure to search for keywords in the issues
filtered by the "regression" or "type::bug" label:
- https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=regression
- https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=type::bug
and verify the issue you're about to submit isn't a duplicate.
--->
### Summary
Jihu Issue: [#4656](https://jihulab.com/gitlab-cn/gitlab/-/issues/4656)
When querying merge requests with filter `Approver=user1`, some merge requests that do NOT take `user1` as an approver will be returned.
### Steps to reproduce
Taking my own account `@luzhiyuan.deer` as an example:
1. Create an approval rule: Let user `@luzhiyuan.deer` approve the `main` branch.
<img src="/uploads/5e7ff7df3b21af3367c64eac1b484a62/image.png" width=400>
1. Create an normal MR. The source branch is `test-soure-branch`, and the target branch is `test-target-branch`. This MR does not need the approval of `@luzhiyuan.deer` because the target branch is not `main`. This is cool :)
<img src="/uploads/989012298d3b0b31a4f9ae8c1b28aafc/image.png" width=400>
1. Use the filter `Approval=luzhiyuan.deer` to query MR and find that the above MR is returned. This is not as expected!
<img src="/uploads/274e8169ddb21e450afa26c65def92a2/image.png" width=400>
1. Furthermore, if we delete the approval rule in the 1st step and repeat the 3rd step at this time, we will see that MR can no longer be returned. This means that when searching MR, the approval rule in step 1 is wrongly used.
### Example Project
https://gitlab.com/test-search-mr-by-approvers/project1/-/merge_requests/?sort=created_date&state=opened&approver%5B%5D=luzhiyuan.deer&first_page_size=20
### What is the current *bug* behavior?
The result of querying the MR is not as expected.
### What is the expected *correct* behavior?
The filter approver can be functioning normally.
### Relevant logs and/or screenshots
<!-- Paste any relevant logs - please use code blocks (```) to format console output, logs, and code
as it's tough to read otherwise. -->
### Output of checks
<!-- If you are reporting a bug on GitLab.com, uncomment below -->
<!-- This bug happens on GitLab.com -->
<!-- and uncomment below if you have /label privileges -->
<!-- /label ~"reproduced on GitLab.com" -->
<!-- or follow up with an issue comment of `@gitlab-bot label ~"reproduced on GitLab.com"` if you do not -->
#### Results of GitLab environment info
<!-- Input any relevant GitLab environment information if needed. -->
<details>
<summary>Expand for output related to GitLab environment info</summary>
<pre>
(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)
(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
</pre>
</details>
#### Results of GitLab application Check
<!-- Input any relevant GitLab application check information if needed. -->
<details>
<summary>Expand for output related to the GitLab application check</summary>
<pre>
(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:check SANITIZE=true`)
(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true`)
(we will only investigate if the tests are passing)
</pre>
</details>
### Possible fixes
I believe the problem is here: https://gitlab.com/gitlab-org/gitlab/-/blob/0f3b36669a5dad8b76a120cde106643b1ab5157b/ee/app/finders/merge_requests/by_approvers_finder.rb#L94
{width=1003 height=537}
When we use approval rules, we should increase consideration for the target branch.
There are many related tables. They are too complex. I would very much like to hear your suggestions for fixing it. 🤯
<!-- If you don't have /label privileges, follow up with an issue comment of `@gitlab-bot label ~"type::bug"` -->
issue