From 8191d503bd6a780ac250702c1715bbaaec9559a0 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Fri, 1 Nov 2024 09:18:07 -1000 Subject: [PATCH 1/2] Remove workspaceRules beta --- src/CONST.ts | 1 - src/libs/Permissions.ts | 5 ----- src/pages/workspace/WorkspaceInitialPage.tsx | 3 +-- src/pages/workspace/WorkspaceMoreFeaturesPage.tsx | 12 ++++-------- .../categories/WorkspaceCategoriesSettingsPage.tsx | 6 ++---- src/pages/workspace/rules/PolicyRulesPage.tsx | 3 +-- .../workspace/tags/WorkspaceTagsSettingsPage.tsx | 4 +--- 7 files changed, 9 insertions(+), 25 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 37d05a661458..437ee4e7fd42 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -621,7 +621,6 @@ const CONST = { DIRECT_FEEDS: 'directFeeds', NETSUITE_USA_TAX: 'netsuiteUsaTax', NEW_DOT_COPILOT: 'newDotCopilot', - WORKSPACE_RULES: 'workspaceRules', COMBINED_TRACK_SUBMIT: 'combinedTrackSubmit', CATEGORY_AND_TAG_APPROVERS: 'categoryAndTagApprovers', PER_DIEM: 'newDotPerDiem', diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index 05a801e6f4ef..a02a456c48fe 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -40,10 +40,6 @@ function canUseNewDotCopilot(betas: OnyxEntry): boolean { return !!betas?.includes(CONST.BETAS.NEW_DOT_COPILOT) || canUseAllBetas(betas); } -function canUseWorkspaceRules(betas: OnyxEntry): boolean { - return !!betas?.includes(CONST.BETAS.WORKSPACE_RULES) || canUseAllBetas(betas); -} - function canUseCategoryAndTagApprovers(betas: OnyxEntry): boolean { return !!betas?.includes(CONST.BETAS.CATEGORY_AND_TAG_APPROVERS) || canUseAllBetas(betas); } @@ -74,7 +70,6 @@ export default { canUseDirectFeeds, canUseNetSuiteUSATax, canUseNewDotCopilot, - canUseWorkspaceRules, canUseCombinedTrackSubmit, canUseCategoryAndTagApprovers, canUsePerDiem, diff --git a/src/pages/workspace/WorkspaceInitialPage.tsx b/src/pages/workspace/WorkspaceInitialPage.tsx index ab347037785d..1ee8a1b890f7 100644 --- a/src/pages/workspace/WorkspaceInitialPage.tsx +++ b/src/pages/workspace/WorkspaceInitialPage.tsx @@ -95,7 +95,6 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac const activeRoute = useNavigationState(getTopmostRouteName); const {translate} = useLocalize(); const {isOffline} = useNetwork(); - const {canUseWorkspaceRules} = usePermissions(); const wasRendered = useRef(false); const prevPendingFields = usePrevious(policy?.pendingFields); @@ -236,7 +235,7 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac }); } - if (featureStates?.[CONST.POLICY.MORE_FEATURES.ARE_RULES_ENABLED] && canUseWorkspaceRules) { + if (featureStates?.[CONST.POLICY.MORE_FEATURES.ARE_RULES_ENABLED]) { protectedCollectPolicyMenuItems.push({ translationKey: 'workspace.common.rules', icon: Expensicons.Feed, diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 1f2f46be6a4a..2c9c2975d1d2 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -63,7 +63,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro const styles = useThemeStyles(); const {shouldUseNarrowLayout} = useResponsiveLayout(); const {translate} = useLocalize(); - const {canUseWorkspaceRules, canUseCompanyCardFeeds} = usePermissions(); + const {canUseCompanyCardFeeds} = usePermissions(); const hasAccountingConnection = !isEmptyObject(policy?.connections); const isAccountingEnabled = !!policy?.areConnectionsEnabled || !isEmptyObject(policy?.connections); const isSyncTaxEnabled = @@ -160,11 +160,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro Policy.enablePolicyWorkflows(policyID, isEnabled); }, }, - ]; - - // TODO remove this when feature will be fully done, and move manage item inside manageItems array - if (canUseWorkspaceRules) { - manageItems.splice(1, 0, { + { icon: Illustrations.Rules, titleTranslationKey: 'workspace.moreFeatures.rules.title', subtitleTranslationKey: 'workspace.moreFeatures.rules.subtitle', @@ -181,8 +177,8 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro } Policy.enablePolicyRules(policyID, isEnabled); }, - }); - } + }, + ]; const earnItems: Item[] = [ { diff --git a/src/pages/workspace/categories/WorkspaceCategoriesSettingsPage.tsx b/src/pages/workspace/categories/WorkspaceCategoriesSettingsPage.tsx index c923bb4460a9..aea6f596badd 100644 --- a/src/pages/workspace/categories/WorkspaceCategoriesSettingsPage.tsx +++ b/src/pages/workspace/categories/WorkspaceCategoriesSettingsPage.tsx @@ -7,7 +7,6 @@ import SelectionList from '@components/SelectionList'; import type {ListItem} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; -import usePermissions from '@hooks/usePermissions'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; import * as OptionsListUtils from '@libs/OptionsListUtils'; @@ -37,7 +36,6 @@ type WorkspaceCategoriesSettingsPageProps = WorkspaceCategoriesSettingsRouteProp function WorkspaceCategoriesSettingsPage({policy, route}: WorkspaceCategoriesSettingsPageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const {canUseWorkspaceRules} = usePermissions(); const isConnectedToAccounting = Object.keys(policy?.connections ?? {}).length > 0; const policyID = route.params.policyID ?? '-1'; const backTo = route.params.backTo; @@ -121,7 +119,7 @@ function WorkspaceCategoriesSettingsPage({policy, route}: WorkspaceCategoriesSet /> - {!!canUseWorkspaceRules && !!currentPolicy && (sections.at(0)?.data?.length ?? 0) > 0 && ( + {!!currentPolicy && (sections.at(0)?.data?.length ?? 0) > 0 && ( @@ -141,7 +139,7 @@ function WorkspaceCategoriesSettingsPage({policy, route}: WorkspaceCategoriesSet }} /> )} - {!!canUseWorkspaceRules && !!categoryID && !!groupID && ( + {!!categoryID && !!groupID && ( diff --git a/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx index eb9b89ee5679..566d7d3910ff 100644 --- a/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx @@ -12,7 +12,6 @@ import Switch from '@components/Switch'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; -import usePermissions from '@hooks/usePermissions'; import useThemeStyles from '@hooks/useThemeStyles'; import * as Tag from '@libs/actions/Policy/Tag'; import Navigation from '@libs/Navigation/Navigation'; @@ -59,7 +58,6 @@ function WorkspaceTagsSettingsPage({route}: WorkspaceTagsSettingsPageProps) { const isLoading = !PolicyUtils.getTagLists(policyTags)?.at(0) || Object.keys(policyTags ?? {}).at(0) === 'undefined'; const {isOffline} = useNetwork(); const hasEnabledOptions = OptionsListUtils.hasEnabledOptions(Object.values(policyTags ?? {}).flatMap(({tags}) => Object.values(tags))); - const {canUseWorkspaceRules} = usePermissions(); const updateWorkspaceRequiresTag = useCallback( (value: boolean) => { Tag.setPolicyRequiresTag(policyID, value); @@ -106,7 +104,7 @@ function WorkspaceTagsSettingsPage({route}: WorkspaceTagsSettingsPageProps) { /> - {!!canUseWorkspaceRules && !!policy?.areRulesEnabled && ( + {!!policy?.areRulesEnabled && ( {translate('workspace.tags.trackBillable')} From 31b4f4cbd9c526d606cd63f12a42c1038440e6ba Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Fri, 1 Nov 2024 09:30:50 -1000 Subject: [PATCH 2/2] Fix linty --- src/pages/workspace/WorkspaceInitialPage.tsx | 1 - src/pages/workspace/rules/PolicyRulesPage.tsx | 1 - 2 files changed, 2 deletions(-) diff --git a/src/pages/workspace/WorkspaceInitialPage.tsx b/src/pages/workspace/WorkspaceInitialPage.tsx index 1ee8a1b890f7..f9d1fedb91c1 100644 --- a/src/pages/workspace/WorkspaceInitialPage.tsx +++ b/src/pages/workspace/WorkspaceInitialPage.tsx @@ -15,7 +15,6 @@ import ScrollView from '@components/ScrollView'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; -import usePermissions from '@hooks/usePermissions'; import usePrevious from '@hooks/usePrevious'; import useSingleExecution from '@hooks/useSingleExecution'; import useThemeStyles from '@hooks/useThemeStyles'; diff --git a/src/pages/workspace/rules/PolicyRulesPage.tsx b/src/pages/workspace/rules/PolicyRulesPage.tsx index 9361b24f7230..bda7870c2186 100644 --- a/src/pages/workspace/rules/PolicyRulesPage.tsx +++ b/src/pages/workspace/rules/PolicyRulesPage.tsx @@ -2,7 +2,6 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React from 'react'; import {View} from 'react-native'; import useLocalize from '@hooks/useLocalize'; -import usePermissions from '@hooks/usePermissions'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import type {FullScreenNavigatorParamList} from '@libs/Navigation/types';