Skip to content

Commit

Permalink
Merge pull request Expensify#51897 from Expensify/marcaaron-removeWor…
Browse files Browse the repository at this point in the history
…kspaceRulesBetaCode

[No QA] Remove `workspaceRules` beta from frontend code
  • Loading branch information
luacmartins authored Nov 1, 2024
2 parents a478cf3 + 31b4f4c commit b86f94e
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 27 deletions.
1 change: 0 additions & 1 deletion src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 0 additions & 5 deletions src/libs/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ function canUseNewDotCopilot(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.NEW_DOT_COPILOT) || canUseAllBetas(betas);
}

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);
}
Expand Down Expand Up @@ -74,7 +70,6 @@ export default {
canUseDirectFeeds,
canUseNetSuiteUSATax,
canUseNewDotCopilot,
canUseWorkspaceRules,
canUseCombinedTrackSubmit,
canUseCategoryAndTagApprovers,
canUsePerDiem,
Expand Down
4 changes: 1 addition & 3 deletions src/pages/workspace/WorkspaceInitialPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -95,7 +94,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);
Expand Down Expand Up @@ -236,7 +234,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,
Expand Down
12 changes: 4 additions & 8 deletions src/pages/workspace/WorkspaceMoreFeaturesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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',
Expand All @@ -181,8 +177,8 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
}
Policy.enablePolicyRules(policyID, isEnabled);
},
});
}
},
];

const earnItems: Item[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -121,7 +119,7 @@ function WorkspaceCategoriesSettingsPage({policy, route}: WorkspaceCategoriesSet
/>
<View style={[styles.sectionDividerLine]} />
<View style={[styles.containerWithSpaceBetween]}>
{!!canUseWorkspaceRules && !!currentPolicy && (sections.at(0)?.data?.length ?? 0) > 0 && (
{!!currentPolicy && (sections.at(0)?.data?.length ?? 0) > 0 && (
<SelectionList
headerContent={
<View style={[styles.mh5, styles.mt2, styles.mb1]}>
Expand All @@ -141,7 +139,7 @@ function WorkspaceCategoriesSettingsPage({policy, route}: WorkspaceCategoriesSet
}}
/>
)}
{!!canUseWorkspaceRules && !!categoryID && !!groupID && (
{!!categoryID && !!groupID && (
<CategorySelectorModal
policyID={policyID}
isVisible={isSelectorModalVisible}
Expand Down
4 changes: 1 addition & 3 deletions src/pages/workspace/rules/PolicyRulesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -21,7 +20,6 @@ function PolicyRulesPage({route}: PolicyRulesPageProps) {
const {policyID} = route.params;
const styles = useThemeStyles();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const {canUseWorkspaceRules} = usePermissions();

return (
<AccessOrNotFoundWrapper
Expand All @@ -37,7 +35,7 @@ function PolicyRulesPage({route}: PolicyRulesPageProps) {
shouldShowOfflineIndicatorInWideScreen
route={route}
icon={Illustrations.Rules}
shouldShowNotFoundPage={!canUseWorkspaceRules}
shouldShowNotFoundPage={false}
shouldShowLoading={false}
>
<View style={[styles.mt3, shouldUseNarrowLayout ? styles.workspaceSectionMobile : styles.workspaceSection]}>
Expand Down
4 changes: 1 addition & 3 deletions src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -106,7 +104,7 @@ function WorkspaceTagsSettingsPage({route}: WorkspaceTagsSettingsPageProps) {
/>
</View>
</OfflineWithFeedback>
{!!canUseWorkspaceRules && !!policy?.areRulesEnabled && (
{!!policy?.areRulesEnabled && (
<OfflineWithFeedback pendingAction={billableExpensesPending(policy)}>
<View style={[styles.flexRow, styles.mh5, styles.mv4, styles.alignItemsCenter, styles.justifyContentBetween]}>
<Text style={[styles.textNormal]}>{translate('workspace.tags.trackBillable')}</Text>
Expand Down

0 comments on commit b86f94e

Please sign in to comment.