diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 77c8bf4f5a05..f37921f07c36 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -31,6 +31,7 @@ type Item = { titleTranslationKey: TranslationPaths; subtitleTranslationKey: TranslationPaths; isActive: boolean; + disabled?: boolean; action: (isEnabled: boolean) => void; pendingAction: PendingAction | undefined; }; @@ -46,6 +47,8 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro const {isSmallScreenWidth} = useWindowDimensions(); const {translate} = useLocalize(); const {canUseAccountingIntegrations} = usePermissions(); + const hasAccountingConnection = !!policy?.areConnectionsEnabled && !!policy?.connections; + const isSyncTaxEnabled = !!policy?.connections?.quickbooksOnline.config.syncTax; const spendItems: Item[] = [ { @@ -76,6 +79,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro titleTranslationKey: 'workspace.moreFeatures.categories.title', subtitleTranslationKey: 'workspace.moreFeatures.categories.subtitle', isActive: policy?.areCategoriesEnabled ?? false, + disabled: hasAccountingConnection, pendingAction: policy?.pendingFields?.areCategoriesEnabled, action: (isEnabled: boolean) => { Policy.enablePolicyCategories(policy?.id ?? '', isEnabled); @@ -86,6 +90,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro titleTranslationKey: 'workspace.moreFeatures.tags.title', subtitleTranslationKey: 'workspace.moreFeatures.tags.subtitle', isActive: policy?.areTagsEnabled ?? false, + disabled: hasAccountingConnection, pendingAction: policy?.pendingFields?.areTagsEnabled, action: (isEnabled: boolean) => { Policy.enablePolicyTags(policy?.id ?? '', isEnabled); @@ -95,7 +100,8 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro icon: Illustrations.Coins, titleTranslationKey: 'workspace.moreFeatures.taxes.title', subtitleTranslationKey: 'workspace.moreFeatures.taxes.subtitle', - isActive: policy?.tax?.trackingEnabled ?? false, + isActive: (policy?.tax?.trackingEnabled ?? false) || isSyncTaxEnabled, + disabled: isSyncTaxEnabled, pendingAction: policy?.pendingFields?.tax, action: (isEnabled: boolean) => { Policy.enablePolicyTaxes(policy?.id ?? '', isEnabled); @@ -150,6 +156,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro isActive={item.isActive} pendingAction={item.pendingAction} onToggle={item.action} + disabled={item.disabled} /> ),