47d4890d changed the order of pagination so that the full list of
branches would be passed to Gitaly to determine which ones had been
merged, but this operation can timeout for large repositories with
many branches. We only need to determine whether the found branches have
been merged, so limit the scan to those.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/55724