Skip to content

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

  1. Create group hierarchy A/B
  2. Create group C
  3. Add user1 as a Guest of C
  4. Invite group C to A as a Guest. This should give user1 access to A and A/B.
  5. As user1, attempt to mention A/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