Hide user of one group from another in search

hi, I created two group, Group A and Group B and each group has a list of users. Now If I am logged in as Group A and search a user from Group B in global search option, can I restrict this?

In simple words, users of Group A should not be able to search any user from Group B or any other group.

This is the search I am talking about. Screenshot attached below

Please share if this is possible.

If you change this setting in the group, only users in the group can see who is in the group. External users can’t see members.

If you search for a user on the site like in your screenshot, it wouldn’t identify what group they are in?


Thanks, I have this setting applied already, but this does not solve my issue.
If I search another group user in the search, it shows the user details, but not the group.
But I wish to hide one group user from another group user in the search.
Is that possible?

I think you would need a plugin doing that.
There are similar topics like All users are visible in @mentions autocomplete list - #2 by pfaffman. You will find more looking at the related topics.