From 6d604aa511c04e6003adf2ab2d65e3f16b4bb053 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Wed, 19 Mar 2025 23:19:12 +0300 Subject: [PATCH 1/4] remove areRulesEnabled check --- .../tags/WorkspaceTagsSettingsPage.tsx | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx index 8401ea31f448a..7365318fef95e 100644 --- a/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx @@ -104,18 +104,16 @@ function WorkspaceTagsSettingsPage({route}: WorkspaceTagsSettingsPageProps) { /> - {!!policy?.areRulesEnabled && ( - - - {translate('workspace.tags.trackBillable')} - toggleBillableExpenses(policy)} - /> - - - )} + + + {translate('workspace.tags.trackBillable')} + toggleBillableExpenses(policy)} + /> + + ); return ( From f889f3a48a26b4acb289f756f2b199dfe31deb29 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Thu, 20 Mar 2025 00:05:56 +0300 Subject: [PATCH 2/4] lint fix --- .../tags/WorkspaceTagsSettingsPage.tsx | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx index 7365318fef95e..8262a9bc895f5 100644 --- a/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx @@ -12,19 +12,19 @@ import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as Tag from '@libs/actions/Policy/Tag'; +import {disableWorkspaceBillableExpenses, setPolicyBillableMode} from '@libs/actions/Policy/Policy'; +import {clearPolicyTagListErrors, setPolicyRequiresTag} from '@libs/actions/Policy/Tag'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; -import * as OptionsListUtils from '@libs/OptionsListUtils'; -import * as PolicyUtils from '@libs/PolicyUtils'; +import {hasEnabledOptions as hasEnabledOptionsUtil} from '@libs/OptionsListUtils'; +import {getTagLists as getTagListsUtil, isMultiLevelTags as isMultiLevelTagsUtil} from '@libs/PolicyUtils'; import type {SettingsNavigatorParamList} from '@navigation/types'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; -import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; -import type * as OnyxTypes from '@src/types/onyx'; +import type {Policy} from '@src/types/onyx'; type WorkspaceTagsSettingsPageProps = PlatformStackScreenProps; @@ -33,18 +33,18 @@ type WorkspaceTagsSettingsPageProps = PlatformStackScreenProps) { +function billableExpensesPending(policy: OnyxEntry) { if (policy?.disabledFields?.defaultBillable) { return policy?.pendingFields?.disabledFields ?? policy?.pendingFields?.defaultBillable; } return policy?.pendingFields?.disabledFields; } -function toggleBillableExpenses(policy: OnyxEntry) { +function toggleBillableExpenses(policy: OnyxEntry) { if (policy?.disabledFields?.defaultBillable) { - Policy.setPolicyBillableMode(policy.id, false); + setPolicyBillableMode(policy.id, false); } else if (policy) { - Policy.disableWorkspaceBillableExpenses(policy.id); + disableWorkspaceBillableExpenses(policy.id); } } @@ -54,24 +54,24 @@ function WorkspaceTagsSettingsPage({route}: WorkspaceTagsSettingsPageProps) { const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`); const styles = useThemeStyles(); const {translate} = useLocalize(); - const [policyTagLists, isMultiLevelTags] = useMemo(() => [PolicyUtils.getTagLists(policyTags), PolicyUtils.isMultiLevelTags(policyTags)], [policyTags]); - const isLoading = !PolicyUtils.getTagLists(policyTags)?.at(0) || Object.keys(policyTags ?? {}).at(0) === 'undefined'; + const [policyTagLists, isMultiLevelTags] = useMemo(() => [getTagListsUtil(policyTags), isMultiLevelTagsUtil(policyTags)], [policyTags]); + const isLoading = !getTagListsUtil(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 hasEnabledOptions = hasEnabledOptionsUtil(Object.values(policyTags ?? {}).flatMap(({tags}) => Object.values(tags))); const updateWorkspaceRequiresTag = useCallback( (value: boolean) => { - Tag.setPolicyRequiresTag(policyID, value); + setPolicyRequiresTag(policyID, value); }, [policyID], ); const isQuickSettingsFlow = !!backTo; - const getTagsSettings = (policy: OnyxEntry) => ( + const getTagsSettings = (policy: OnyxEntry) => ( {!isMultiLevelTags && ( Tag.clearPolicyTagListErrors(policyID, policyTagLists.at(0)?.orderWeight ?? 0)} + onClose={() => clearPolicyTagListErrors(policyID, policyTagLists.at(0)?.orderWeight ?? 0)} pendingAction={policyTags?.[policyTagLists.at(0)?.name ?? '']?.pendingAction} errorRowStyles={styles.mh5} > From 5780fa24127948fa8b0ba7f46e217cd33c500df5 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Thu, 20 Mar 2025 21:31:53 +0300 Subject: [PATCH 3/4] lint fix --- src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx index 8262a9bc895f5..92b41a2aa7a61 100644 --- a/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx @@ -49,7 +49,7 @@ function toggleBillableExpenses(policy: OnyxEntry) { } function WorkspaceTagsSettingsPage({route}: WorkspaceTagsSettingsPageProps) { - const policyID = route.params.policyID ?? '-1'; + const policyID = route.params.policyID; const backTo = route.params.backTo; const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`); const styles = useThemeStyles(); From d264e2d2e732cf55d9e48cf86cb1c888eaacc056 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Fri, 21 Mar 2025 15:43:50 +0300 Subject: [PATCH 4/4] disable when tags are disabled --- src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx index 92b41a2aa7a61..23153aedef03c 100644 --- a/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx @@ -111,6 +111,7 @@ function WorkspaceTagsSettingsPage({route}: WorkspaceTagsSettingsPageProps) { isOn={!(policy?.disabledFields?.defaultBillable ?? false)} accessibilityLabel={translate('workspace.tags.trackBillable')} onToggle={() => toggleBillableExpenses(policy)} + disabled={!policy?.areTagsEnabled} />