fix: Unify handling of exclude groups in contacts menu and sharing #56938
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If the current user belongs to both one or more groups excluded from sharing and one or more groups not excluded from sharing the user is allowed to share. However, in the contacts menu, as soon as the current user belonged to a group excluded from sharing the user could not search for local contacts. This has been unified now with the sharing behaviour, so local contacts can still be searched if the user also belongs to a group not excluded from sharing (or to no group at all, which was also allowed before).
Important
Being able to share if the current user belongs to both groups excluded from sharing and other groups has been there since handling excluded groups was added for sharing. There is unfortunately no context about it (it seems to predate Nextcloud). However, unifying the behaviour between sharing and contacts menu to be like in the contacts menu (that is, preventing sharing) could be a breaking behaviour change.
On the other hand, not showing the contacts when belonging to both groups excluded from sharing and other groups was an explicit decision when adding handling of excluded groups for contacts. However, it might be just a cautious implementation to fix the issues described in #5107, and in any case it does not prevent finding other local users due to those users appearing as internal share candidates. Therefore, unifying the behaviour to show the contacts when belonging to both excluded and not excluded groups should not be problematic... but please double check that I did not miss anything :-)
How to test
Result with this pull request
User Target appears in the contacts menu, just like in the share candidates
Result without this pull request
User Target does not appear in the contacts menu