Fix creating merge requests with approval rules
What does this MR do?
Fixes creating merge requests with approval rules. It failed because any_approver approval rules have groups but they shouldn't. If those groups are hidden to a user, they are appended to rule attributes: https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/app/services/approval_rules/params_filtering_service.rb#L48 and rule_attributes[:group_ids]
are no longer empty on the https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/app/services/approval_rules/params_filtering_service.rb#L56
This merge request fixes the MR creation with such rules.
The data can be fixed later. We have a bunch of such incorrect records on production:
SELECT approval_project_rules.* FROM approval_project_rules INNER JOIN approval_project_rules_groups ON approval_project_rules_groups.approval_project_rule_id = approval_project_rules.id WHERE approval_project_rules.rule_type = 3
Hash Join (cost=2879.64..3569.07 rows=8811 width=42) (actual time=113.167..122.850 rows=1164 loops=1)
Hash Cond: (approval_project_rules_groups.approval_project_rule_id = approval_project_rules.id)
Buffers: shared hit=32168 read=343
I/O Timings: read=41.061
-> Index Only Scan using index_approval_project_rules_groups_1 on approval_project_rules_groups (cost=0.29..634.50 rows=21035 width=8) (actual time=0.025..9.994 rows=21054 loops=1)
Heap Fetches: 7347
Buffers: shared hit=4959 read=11
I/O Timings: read=2.308
-> Hash (cost=2341.05..2341.05 rows=43064 width=42) (actual time=107.309..107.309 rows=43081 loops=1)
Buckets: 65536 Batches: 1 Memory Usage: 3710kB
Buffers: shared hit=27206 read=332
I/O Timings: read=38.753
-> Index Scan using any_approver_project_rule_type_unique_index on approval_project_rules (cost=0.29..2341.05 rows=43064 width=42) (actual time=1.995..92.041 rows=43081 loops=1)
Buffers: shared hit=27206 read=332
I/O Timings: read=38.753
Planning Time: 3.006 ms
Related issue: https://gitlab.com/gitlab-org/gitlab/-/issues/208978#note_353379792