From 441415f6c682301c4b63996caabe84573a9f7a8a Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Wed, 24 Apr 2024 15:11:14 -0400 Subject: [PATCH 1/5] fix: prevent the user from disabling accounting feature when there is an active accounting connection --- src/pages/workspace/WorkspaceMoreFeaturesPage.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 66e6b87d79d3..323d84a3bd36 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -47,7 +47,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro const {isSmallScreenWidth} = useWindowDimensions(); const {translate} = useLocalize(); const {canUseAccountingIntegrations} = usePermissions(); - const hasAccountingConnection = !!policy?.areConnectionsEnabled && !!policy?.connections; + const hasAccountingConnection = !!policy?.areConnectionsEnabled && Object.keys(policy?.connections ?? {}).length > 0; const isSyncTaxEnabled = !!policy?.connections?.quickbooksOnline?.config?.syncTax; const spendItems: Item[] = [ @@ -119,6 +119,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro action: (isEnabled: boolean) => { Policy.enablePolicyConnections(policy?.id ?? '', isEnabled); }, + disabled: !hasAccountingConnection, }, ]; From 1c2074626a0edfb9b72d6c1cf659fdfa16843c7a Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Wed, 24 Apr 2024 16:05:04 -0400 Subject: [PATCH 2/5] fix: fetch the connections data and check if there is an active connection to any of the accounting software --- src/pages/workspace/WorkspaceMoreFeaturesPage.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 323d84a3bd36..73a000e489ed 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -21,7 +21,7 @@ import type IconAsset from '@src/types/utils/IconAsset'; import AdminPolicyAccessOrNotFoundWrapper from './AdminPolicyAccessOrNotFoundWrapper'; import PaidPolicyAccessOrNotFoundWrapper from './PaidPolicyAccessOrNotFoundWrapper'; import type {WithPolicyAndFullscreenLoadingProps} from './withPolicyAndFullscreenLoading'; -import withPolicyAndFullscreenLoading from './withPolicyAndFullscreenLoading'; +import withPolicyConnections from './withPolicyConnections'; import ToggleSettingOptionRow from './workflows/ToggleSettingsOptionRow'; type WorkspaceMoreFeaturesPageProps = WithPolicyAndFullscreenLoadingProps & StackScreenProps; @@ -119,7 +119,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro action: (isEnabled: boolean) => { Policy.enablePolicyConnections(policy?.id ?? '', isEnabled); }, - disabled: !hasAccountingConnection, + disabled: hasAccountingConnection, }, ]; @@ -220,4 +220,4 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro WorkspaceMoreFeaturesPage.displayName = 'WorkspaceMoreFeaturesPage'; -export default withPolicyAndFullscreenLoading(WorkspaceMoreFeaturesPage); +export default withPolicyConnections(WorkspaceMoreFeaturesPage); From 6a7eef71707fa8bf4b0f178d53e76960e0f0223b Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Wed, 1 May 2024 11:43:21 -0700 Subject: [PATCH 3/5] fix: remove the usage of `withPolicyConnections` --- src/pages/workspace/WorkspaceMoreFeaturesPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 73a000e489ed..67e6f0c4bd0b 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -21,7 +21,7 @@ import type IconAsset from '@src/types/utils/IconAsset'; import AdminPolicyAccessOrNotFoundWrapper from './AdminPolicyAccessOrNotFoundWrapper'; import PaidPolicyAccessOrNotFoundWrapper from './PaidPolicyAccessOrNotFoundWrapper'; import type {WithPolicyAndFullscreenLoadingProps} from './withPolicyAndFullscreenLoading'; -import withPolicyConnections from './withPolicyConnections'; +import withPolicyAndFullscreenLoading from './withPolicyAndFullscreenLoading'; import ToggleSettingOptionRow from './workflows/ToggleSettingsOptionRow'; type WorkspaceMoreFeaturesPageProps = WithPolicyAndFullscreenLoadingProps & StackScreenProps; @@ -220,4 +220,4 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro WorkspaceMoreFeaturesPage.displayName = 'WorkspaceMoreFeaturesPage'; -export default withPolicyConnections(WorkspaceMoreFeaturesPage); +export default withPolicyAndFullscreenLoading(WorkspaceMoreFeaturesPage); From a650982b9a4030612207950fa700f73099fe109d Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Wed, 1 May 2024 11:47:24 -0700 Subject: [PATCH 4/5] feat: ensure fetching policy connections on the more features page --- src/pages/workspace/WorkspaceMoreFeaturesPage.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index f9cce40e3400..d57f9fb5ece2 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -10,6 +10,7 @@ import Section from '@components/Section'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import usePermissions from '@hooks/usePermissions'; +import usePolicyConnections from '@hooks/usePolicyWithConnections'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import type {WorkspacesCentralPaneNavigatorParamList} from '@libs/Navigation/types'; @@ -44,6 +45,7 @@ type SectionObject = { }; function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPageProps) { + usePolicyConnections(policy?.id ?? ''); const styles = useThemeStyles(); const {isSmallScreenWidth} = useWindowDimensions(); const {translate} = useLocalize(); From ef2f42876941f2961aacc3d95e8d19fa9a7b1af5 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Thu, 2 May 2024 13:20:26 -0700 Subject: [PATCH 5/5] chore: remove non-existing hook --- src/pages/workspace/WorkspaceMoreFeaturesPage.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index eaeaf40bba9a..6ef72b228a20 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -10,7 +10,6 @@ import Section from '@components/Section'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import usePermissions from '@hooks/usePermissions'; -import usePolicyConnections from '@hooks/usePolicyWithConnections'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import * as ErrorUtils from '@libs/ErrorUtils'; @@ -48,7 +47,6 @@ type SectionObject = { }; function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPageProps) { - usePolicyConnections(policy?.id ?? ''); const styles = useThemeStyles(); const {isSmallScreenWidth} = useWindowDimensions(); const {translate} = useLocalize();