diff --git a/src/CONST.ts b/src/CONST.ts index 075f661b8822..03ed29ab8097 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -480,6 +480,7 @@ const CONST = { NEW_DOT_COPILOT: 'newDotCopilot', WORKSPACE_RULES: 'workspaceRules', COMBINED_TRACK_SUBMIT: 'combinedTrackSubmit', + CATEGORY_AND_TAG_APPROVERS: 'categoryAndTagApprovers', NEW_DOT_QBD: 'quickbooksDesktopOnNewDot', }, BUTTON_STATES: { diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index 12f5d59a025d..ce3c8bc73aed 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -45,6 +45,10 @@ function canUseWorkspaceRules(betas: OnyxEntry<Beta[]>): boolean { return !!betas?.includes(CONST.BETAS.WORKSPACE_RULES) || canUseAllBetas(betas); } +function canUseCategoryAndTagApprovers(betas: OnyxEntry<Beta[]>): boolean { + return !!betas?.includes(CONST.BETAS.CATEGORY_AND_TAG_APPROVERS) || canUseAllBetas(betas); +} + function canUseCombinedTrackSubmit(betas: OnyxEntry<Beta[]>): boolean { // We don't need to show this to all betas since this will be used for developing a feature for A/B testing. return !!betas?.includes(CONST.BETAS.COMBINED_TRACK_SUBMIT); @@ -85,5 +89,6 @@ export default { canUseWorkspaceRules, canUseCombinedTrackSubmit, canUseNewSearchRouter, + canUseCategoryAndTagApprovers, canUseNewDotQBD, }; diff --git a/src/pages/workspace/categories/CategorySettingsPage.tsx b/src/pages/workspace/categories/CategorySettingsPage.tsx index e03412d8eafc..137d32fb0b78 100644 --- a/src/pages/workspace/categories/CategorySettingsPage.tsx +++ b/src/pages/workspace/categories/CategorySettingsPage.tsx @@ -14,6 +14,7 @@ import Switch from '@components/Switch'; import Text from '@components/Text'; import TextLink from '@components/TextLink'; import useLocalize from '@hooks/useLocalize'; +import usePermissions from '@hooks/usePermissions'; import usePolicy from '@hooks/usePolicy'; import useThemeStyles from '@hooks/useThemeStyles'; import * as CategoryUtils from '@libs/CategoryUtils'; @@ -43,6 +44,7 @@ function CategorySettingsPage({ const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`); const styles = useThemeStyles(); const {translate} = useLocalize(); + const {canUseCategoryAndTagApprovers} = usePermissions(); const [deleteCategoryConfirmModalVisible, setDeleteCategoryConfirmModalVisible] = useState(false); const policy = usePolicy(policyID); @@ -255,26 +257,30 @@ function CategorySettingsPage({ /> </OfflineWithFeedback> )} - <MenuItemWithTopDescription - title={approverText} - description={translate('workspace.rules.categoryRules.approver')} - onPress={() => { - Navigation.navigate(ROUTES.WORSKPACE_CATEGORY_APPROVER.getRoute(policyID, policyCategory.name)); - }} - shouldShowRightIcon - disabled={approverDisabled} - /> - {approverDisabled && ( - <Text style={[styles.flexRow, styles.alignItemsCenter, styles.mv2, styles.mh5]}> - <Text style={[styles.textLabel, styles.colorMuted]}>{translate('workspace.rules.categoryRules.goTo')}</Text>{' '} - <TextLink - style={[styles.link, styles.label]} - onPress={() => Navigation.navigate(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID))} - > - {translate('workspace.common.moreFeatures')} - </TextLink>{' '} - <Text style={[styles.textLabel, styles.colorMuted]}>{translate('workspace.rules.categoryRules.andEnableWorkflows')}</Text> - </Text> + {canUseCategoryAndTagApprovers && ( + <> + <MenuItemWithTopDescription + title={approverText} + description={translate('workspace.rules.categoryRules.approver')} + onPress={() => { + Navigation.navigate(ROUTES.WORSKPACE_CATEGORY_APPROVER.getRoute(policyID, policyCategory.name)); + }} + shouldShowRightIcon + disabled={approverDisabled} + /> + {approverDisabled && ( + <Text style={[styles.flexRow, styles.alignItemsCenter, styles.mv2, styles.mh5]}> + <Text style={[styles.textLabel, styles.colorMuted]}>{translate('workspace.rules.categoryRules.goTo')}</Text>{' '} + <TextLink + style={[styles.link, styles.label]} + onPress={() => Navigation.navigate(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID))} + > + {translate('workspace.common.moreFeatures')} + </TextLink>{' '} + <Text style={[styles.textLabel, styles.colorMuted]}>{translate('workspace.rules.categoryRules.andEnableWorkflows')}</Text> + </Text> + )} + </> )} {policy?.tax?.trackingEnabled && ( <MenuItemWithTopDescription diff --git a/src/pages/workspace/tags/TagSettingsPage.tsx b/src/pages/workspace/tags/TagSettingsPage.tsx index f5599ed4c269..aedd7e36a274 100644 --- a/src/pages/workspace/tags/TagSettingsPage.tsx +++ b/src/pages/workspace/tags/TagSettingsPage.tsx @@ -13,6 +13,7 @@ import Switch from '@components/Switch'; import Text from '@components/Text'; import TextLink from '@components/TextLink'; import useLocalize from '@hooks/useLocalize'; +import usePermissions from '@hooks/usePermissions'; import usePolicy from '@hooks/usePolicy'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ErrorUtils from '@libs/ErrorUtils'; @@ -38,7 +39,7 @@ function TagSettingsPage({route, navigation}: TagSettingsPageProps) { const policyTag = useMemo(() => PolicyUtils.getTagList(policyTags, orderWeight), [policyTags, orderWeight]); const policy = usePolicy(policyID); const hasAccountingConnections = PolicyUtils.hasAccountingConnections(policy); - + const {canUseCategoryAndTagApprovers} = usePermissions(); const [isDeleteTagModalOpen, setIsDeleteTagModalOpen] = React.useState(false); const currentPolicyTag = policyTag.tags[tagName] ?? Object.values(policyTag.tags ?? {}).find((tag) => tag.previousTagName === tagName); @@ -153,7 +154,7 @@ function TagSettingsPage({route, navigation}: TagSettingsPageProps) { /> </OfflineWithFeedback> - {policy?.areRulesEnabled && ( + {policy?.areRulesEnabled && canUseCategoryAndTagApprovers && ( <> <View style={[styles.mh5, styles.mv3, styles.pt3, styles.borderTop]}> <Text style={[styles.textNormal, styles.textStrong, styles.mv3]}>{translate('workspace.tags.tagRules')}</Text>