Descendants of groups via shared group membership does not show in mention autocomplete
Summary
Descendants of groups via shared group membership does not show in mention autocomplete
Steps to reproduce
- Create group hierarchy
A/B
- Create group
C
- Add
user1
as a Guest ofC
- Invite group
C
toA
as a Guest. This should giveuser1
access toA
andA/B
. - As
user1
, attempt to mentionA/B
- it does not show in the autocomplete
What is the current bug behavior?
Descendants of groups via shared group membership does not show in mention autocomplete
What is the expected correct behavior?
Autocomplete should show all descendent groups where the user is a member.
Possible fixes
diff --git a/app/models/user.rb b/app/models/user.rb
index 096f7dee97fe..59452eb62402 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1291,6 +1291,7 @@ def authorized_groups
Group.id_in(authorized_projects.select(:namespace_id)),
Group.joins(:shared_with_group_links)
.where(group_group_links: { shared_with_group_id: Group.from(direct_groups_cte_alias) })
+ .self_and_descendants
])
end
end
Edited by Heinrich Lee Yu