Altium 365 workspace administration may need to display only users with selected roles, such as Designer or Administrator. Implement a function that returns a new array containing only users whose role appears in the allowed roles list.
The result must preserve the original user order, include each matching user at most once, and leave the input arrays unchanged. Role matching is case-sensitive and requires an exact string match.
Implement filter_workspace_users(users, allowed_roles).
users is an array of objects. Each object contains a string name and a string role.allowed_roles is an array of role strings. It may contain duplicate values.role is included in allowed_roles.users or allowed_roles.Use a data structure that keeps role membership checks efficient when the input is large.
def filter_workspace_users(users, allowed_roles):