Consider duplicating shared group members in shared with group members

This came from the discussion in #219230 (comment 368889853).

An alternative proposal, #195423 (closed) is about creating a similar solution to project_authorizations where we cache every users effective access level to all their projects. The difference is that this issue only considers duplicating shared group members. The goal is to reduce the number of synchronization issues, while still making group authorization queries performant.

Some concerns / edge cases:

  • cyclic dependency
  • do we need to duplicate direct members only or inherited members too?
  • users might end up having multiple memberships: direct membership, inherited membership from parent group, memberships from multiple shared groups. If a group share access level changes, we need to sync the related duplicate entry.

cc @alexpooley, @lmcandrew, @mushakov

Edited by Imre Farkas