Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: ws options available from all devices for same user #42008

Merged
merged 14 commits into from
May 31, 2024
4 changes: 2 additions & 2 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ function isExpensifyTeam(email: string | undefined): boolean {
/**
* Checks if the current user is an admin of the policy.
*/
const isPolicyAdmin = (policy: OnyxEntry<Policy> | EmptyObject): boolean => policy?.role === CONST.POLICY.ROLE.ADMIN;

const isPolicyAdmin = (policy: OnyxEntry<Policy> | EmptyObject): boolean =>
policy?.role === CONST.POLICY.ROLE.ADMIN || policy?.employeeList?.[policy?.owner]?.role === CONST.POLICY.ROLE.ADMIN;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should check the role of the current user accountID here. Or it'll introduce regression - non-admin members can also see protected items.

Screen.Recording.2024-05-13.at.8.38.33.PM.mov

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the note. Working on it..

/**
* Checks if the policy is a free group policy.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/WorkspaceInitialPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, reimbursementAcc
const hasMembersError = PolicyUtils.hasEmployeeListError(policy);
const hasPolicyCategoryError = PolicyUtils.hasPolicyCategoriesError(policyCategories);
const hasGeneralSettingsError = !isEmptyObject(policy?.errorFields?.generalSettings ?? {}) || !isEmptyObject(policy?.errorFields?.avatarURL ?? {});
const shouldShowProtectedItems = PolicyUtils.isPolicyAdmin(policy);
const shouldShowProtectedItems = PolicyUtils.isPolicyAdmin(policyProp);
const isPaidGroupPolicy = PolicyUtils.isPaidGroupPolicy(policy);
const isFreeGroupPolicy = PolicyUtils.isFreeGroupPolicy(policy);
const [featureStates, setFeatureStates] = useState(policyFeatureStates);
Expand Down
Loading