Is it possible to set this privacy setting?

Is it possible to set up such a system?

Is it possible to add a function that allows people to only see the email addresses of people with the same affiliation?
For example, people are divided into Groups A, B and C. People in Group A can see the email addresses of people in Group A, but not those in Groups B and C.

Group A people → ○ Group A people’s email address | × Group B and C people’s email address
Group B people → ○ Group B people’s email address | × Group A and C people’s email address
Group C people → ○ Group C people’s email address | × Group A and B people’s email address

If your User data type has a thing called Group, the following privacy setting would give you what you need:

However, the group should just be a single thing. I have tried with lists and what not, but the expression editor in the privacy tab is not that sophisticated.

thanks