diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index a8c0508e30b6..a85e97a4cf05 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -108,6 +108,11 @@ function isExpensifyGuideTeam(email: string): boolean { */ const isPolicyAdmin = (policy: OnyxEntry | EmptyObject): boolean => policy?.role === CONST.POLICY.ROLE.ADMIN; +/** + * Checks if the policy is a free group policy. + */ +const isFreeGroupPolicy = (policy: OnyxEntry | EmptyObject): boolean => policy?.type === CONST.POLICY.TYPE.FREE; + const isPolicyMember = (policyID: string, policies: OnyxCollection): boolean => Object.values(policies ?? {}).some((policy) => policy?.id === policyID); /** @@ -258,6 +263,7 @@ export { isExpensifyTeam, isExpensifyGuideTeam, isInstantSubmitEnabled, + isFreeGroupPolicy, isPolicyAdmin, isSubmitAndClose, getMemberAccountIDsForWorkspace, diff --git a/src/pages/workspace/WorkspaceInitialPage.tsx b/src/pages/workspace/WorkspaceInitialPage.tsx index 07049a91bee9..70d871849ee6 100644 --- a/src/pages/workspace/WorkspaceInitialPage.tsx +++ b/src/pages/workspace/WorkspaceInitialPage.tsx @@ -98,8 +98,10 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r const hasGeneralSettingsError = !isEmptyObject(policy?.errorFields?.generalSettings ?? {}) || !isEmptyObject(policy?.errorFields?.avatar ?? {}); const shouldShowProtectedItems = PolicyUtils.isPolicyAdmin(policy); + const isPaidGroupPolicy = PolicyUtils.isPaidGroupPolicy(policy); + const isFreeGroupPolicy = PolicyUtils.isFreeGroupPolicy(policy); - const protectedMenuItems: WorkspaceMenuItem[] = [ + const protectedFreePolicyMenuItems: WorkspaceMenuItem[] = [ { translationKey: 'workspace.common.card', icon: Expensicons.ExpensifyCard, @@ -148,6 +150,16 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r }, ]; + const protectedCollectPolicyMenuItems: WorkspaceMenuItem[] = [ + { + translationKey: 'workspace.common.members', + icon: Expensicons.Users, + action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_MEMBERS.getRoute(policyID)))), + brickRoadIndicator: hasMembersError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, + routeName: SCREENS.WORKSPACE.MEMBERS, + }, + ]; + const menuItems: WorkspaceMenuItem[] = [ { translationKey: 'workspace.common.profile', @@ -156,7 +168,8 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r brickRoadIndicator: hasGeneralSettingsError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, routeName: SCREENS.WORKSPACE.PROFILE, }, - ...(shouldShowProtectedItems ? protectedMenuItems : []), + ...(isPaidGroupPolicy && shouldShowProtectedItems ? protectedCollectPolicyMenuItems : []), + ...(isFreeGroupPolicy && shouldShowProtectedItems ? protectedFreePolicyMenuItems : []), ]; const prevPolicy = usePrevious(policy);