From 5c5c2771c7b5437a37d9026e11f18b2dad70e06e Mon Sep 17 00:00:00 2001 From: Yauheni Date: Wed, 16 Oct 2024 15:14:41 +0200 Subject: [PATCH 1/8] restrict QBD to Control plans --- src/CONST.ts | 8 +++++++ src/languages/en.ts | 5 +++++ src/languages/es.ts | 5 +++++ .../accounting/AccountingContext.tsx | 7 +++++- src/pages/workspace/accounting/types.ts | 2 ++ src/pages/workspace/accounting/utils.tsx | 22 +++++++++++++++++++ 6 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/CONST.ts b/src/CONST.ts index 399535412f0e..f00557914d76 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -5765,6 +5765,14 @@ const CONST = { description: `workspace.upgrade.${this.POLICY.CONNECTIONS.NAME.SAGE_INTACCT}.description` as const, icon: 'IntacctSquare', }, + [this.POLICY.CONNECTIONS.NAME.QBD]: { + id: this.POLICY.CONNECTIONS.NAME.QBD, + alias: 'qbd', + name: this.POLICY.CONNECTIONS.NAME_USER_FRIENDLY.quickbooksDesktop, + title: `workspace.upgrade.${this.POLICY.CONNECTIONS.NAME.QBD}.title` as const, + description: `workspace.upgrade.${this.POLICY.CONNECTIONS.NAME.QBD}.description` as const, + icon: 'QBDSquare', + }, approvals: { id: 'approvals' as const, alias: 'approvals' as const, diff --git a/src/languages/en.ts b/src/languages/en.ts index 15efa7947cf7..aad51962015c 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -3961,6 +3961,11 @@ const translations = { description: `Enjoy automated syncing and reduce manual entries with the Expensify + Sage Intacct integration. Gain in-depth, real-time financial insights with user-defined dimensions, as well as expense coding by department, class, location, customer, and project (job).`, onlyAvailableOnPlan: 'Our Sage Intacct integration is only available on the Control plan, starting at ', }, + [CONST.POLICY.CONNECTIONS.NAME.QBD]: { + title: 'QuickBooks Desktop', + description: `Enjoy automated syncing and reduce manual entries with the Expensify + QuickBooks Desktop integration. Gain ultimate efficiency with a realtime, two-way connection and expense coding by class, item, customer, and project.`, + onlyAvailableOnPlan: 'Our QuickBooks Desktop integration is only available on the Control plan, starting at ', + }, [CONST.UPGRADE_FEATURE_INTRO_MAPPING.approvals.id]: { title: 'Advanced Approvals', description: `If you want to add more layers of approval to the mix – or just make sure the largest expenses get another set of eyes – we’ve got you covered. Advanced approvals help you put the right checks in place at every level so you keep your team’s spend under control.`, diff --git a/src/languages/es.ts b/src/languages/es.ts index f3bfd43c760b..f0eb9a13ee46 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -4006,6 +4006,11 @@ const translations = { description: `Disfruta de una sincronización automatizada y reduce las entradas manuales con la integración Expensify + Sage Intacct. Obtén información financiera en profundidad y en tiempo real con dimensiones definidas por el usuario, así como codificación de gastos por departamento, clase, ubicación, cliente y proyecto (trabajo).`, onlyAvailableOnPlan: 'Nuestra integración Sage Intacct sólo está disponible en el plan Control, a partir de ', }, + [CONST.POLICY.CONNECTIONS.NAME.QBD]: { + title: 'QuickBooks Desktop', + description: `Disfruta de la sincronización automática y reduce las entradas manuales con la integración de Expensify + QuickBooks Desktop. Obtén la máxima eficiencia con una conexión bidireccional en tiempo real y la codificación de gastos por clase, artículo, cliente y proyecto.`, + onlyAvailableOnPlan: 'Nuestra integración con QuickBooks Desktop solo está disponible en el plan Control, que comienza en ', + }, [CONST.UPGRADE_FEATURE_INTRO_MAPPING.approvals.id]: { title: 'Aprobaciones anticipadas', description: `Si quieres añadir más niveles de aprobación, o simplemente asegurarte de que los gastos más importantes reciben otro vistazo, no hay problema. Las aprobaciones avanzadas ayudan a realizar las comprobaciones adecuadas a cada nivel para mantener los gastos de tu equipo bajo control.`, diff --git a/src/pages/workspace/accounting/AccountingContext.tsx b/src/pages/workspace/accounting/AccountingContext.tsx index 6250f99b21f2..1ffe87d672af 100644 --- a/src/pages/workspace/accounting/AccountingContext.tsx +++ b/src/pages/workspace/accounting/AccountingContext.tsx @@ -4,6 +4,7 @@ import type {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import AccountingConnectionConfirmationModal from '@components/AccountingConnectionConfirmationModal'; import useLocalize from '@hooks/useLocalize'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; import {removePolicyConnection} from '@libs/actions/connections'; import Navigation from '@libs/Navigation/Navigation'; import {isControlPolicy} from '@libs/PolicyUtils'; @@ -56,6 +57,7 @@ function AccountingContextProvider({children, policy}: AccountingContextProvider const [activeIntegration, setActiveIntegration] = useState(); const {translate} = useLocalize(); const policyID = policy?.id ?? '-1'; + const {isSmallScreenWidth} = useResponsiveLayout(); const startIntegrationFlow = React.useCallback( (newActiveIntegration: ActiveIntegration) => { @@ -67,9 +69,12 @@ function AccountingContextProvider({children, policy}: AccountingContextProvider undefined, newActiveIntegration.integrationToDisconnect, newActiveIntegration.shouldDisconnectIntegrationBeforeConnecting, + isSmallScreenWidth, ); const workspaceUpgradeNavigationDetails = accountingIntegrationData?.workspaceUpgradeNavigationDetails; if (workspaceUpgradeNavigationDetails && !isControlPolicy(policy)) { + workspaceUpgradeNavigationDetails.sideEffect?.(); + Navigation.navigate( ROUTES.WORKSPACE_UPGRADE.getRoute(policyID, workspaceUpgradeNavigationDetails.integrationAlias, workspaceUpgradeNavigationDetails.backToAfterWorkspaceUpgradeRoute), ); @@ -80,7 +85,7 @@ function AccountingContextProvider({children, policy}: AccountingContextProvider key: Math.random(), }); }, - [policy, policyID, translate], + [isSmallScreenWidth, policy, policyID, translate], ); const closeConfirmationModal = () => { diff --git a/src/pages/workspace/accounting/types.ts b/src/pages/workspace/accounting/types.ts index 4ff7728e5575..e05ceae1db3a 100644 --- a/src/pages/workspace/accounting/types.ts +++ b/src/pages/workspace/accounting/types.ts @@ -22,6 +22,8 @@ type WorkspaceUpgradeNavigationDetails = { integrationAlias: string; /** Route to redirect to after upgrading the workspace */ backToAfterWorkspaceUpgradeRoute: string; + /** Function to call after upgrading the workspace */ + sideEffect?: () => void; }; type AccountingIntegration = { diff --git a/src/pages/workspace/accounting/utils.tsx b/src/pages/workspace/accounting/utils.tsx index cc1dfa1fcd9f..661110fd172e 100644 --- a/src/pages/workspace/accounting/utils.tsx +++ b/src/pages/workspace/accounting/utils.tsx @@ -15,6 +15,7 @@ import {canUseTaxNetSuite} from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; import type {ThemeStyles} from '@styles/index'; import {getTrackingCategories} from '@userActions/connections/Xero'; +import * as PolicyAction from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import type {Policy} from '@src/types/onyx'; @@ -47,11 +48,22 @@ function getAccountingIntegrationData( integrationToDisconnect?: ConnectionName, shouldDisconnectIntegrationBeforeConnecting?: boolean, canUseNetSuiteUSATax?: boolean, + isSmallScreenWidth?: boolean, ): AccountingIntegration | undefined { const qboConfig = policy?.connections?.quickbooksOnline?.config; const netsuiteConfig = policy?.connections?.netsuite?.options?.config; const netsuiteSelectedSubsidiary = (policy?.connections?.netsuite?.options?.data?.subsidiaryList ?? []).find((subsidiary) => subsidiary.internalID === netsuiteConfig?.subsidiaryID); + const getBackToAfterWorkspaceUpgradeRouteForQBD = () => { + if (integrationToDisconnect) { + return ROUTES.POLICY_ACCOUNTING.getRoute(policyID, connectionName, integrationToDisconnect, shouldDisconnectIntegrationBeforeConnecting); + } + if (isSmallScreenWidth) { + return ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_SETUP_REQUIRED_DEVICE_MODAL.getRoute(policyID); + } + return ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_SETUP_MODAL.getRoute(policyID); + }; + switch (connectionName) { case CONST.POLICY.CONNECTIONS.NAME.QBO: return { @@ -270,6 +282,16 @@ function getAccountingIntegrationData( CONST.QUICKBOOKS_DESKTOP_CONFIG.MARK_CHECKS_TO_BE_PRINTED, ], subscribedAdvancedSettings: [CONST.QUICKBOOKS_DESKTOP_CONFIG.SHOULD_AUTO_CREATE_VENDOR, CONST.QUICKBOOKS_DESKTOP_CONFIG.AUTO_SYNC], + workspaceUpgradeNavigationDetails: { + integrationAlias: CONST.UPGRADE_FEATURE_INTRO_MAPPING.quickbooksDesktop.alias, + sideEffect: () => { + if (isSmallScreenWidth) { + return; + } + PolicyAction.enablePolicyTaxes(policyID, false); + }, + backToAfterWorkspaceUpgradeRoute: getBackToAfterWorkspaceUpgradeRouteForQBD(), + }, }; default: return undefined; From e7d59390e378e044dc7f8a1864b2b5b904fa0328 Mon Sep 17 00:00:00 2001 From: Yauheni Date: Wed, 16 Oct 2024 15:31:34 +0200 Subject: [PATCH 2/8] update condition for side effect --- src/pages/workspace/accounting/utils.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/utils.tsx b/src/pages/workspace/accounting/utils.tsx index 661110fd172e..1aebb56b30b5 100644 --- a/src/pages/workspace/accounting/utils.tsx +++ b/src/pages/workspace/accounting/utils.tsx @@ -285,7 +285,8 @@ function getAccountingIntegrationData( workspaceUpgradeNavigationDetails: { integrationAlias: CONST.UPGRADE_FEATURE_INTRO_MAPPING.quickbooksDesktop.alias, sideEffect: () => { - if (isSmallScreenWidth) { + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + if (isSmallScreenWidth || integrationToDisconnect) { return; } PolicyAction.enablePolicyTaxes(policyID, false); From 210fa0913f0b408227a9f4dedb1bef87129deaca Mon Sep 17 00:00:00 2001 From: Yauheni Date: Wed, 16 Oct 2024 15:46:02 +0200 Subject: [PATCH 3/8] fix bug with small screens --- src/pages/workspace/accounting/AccountingContext.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/accounting/AccountingContext.tsx b/src/pages/workspace/accounting/AccountingContext.tsx index 1ffe87d672af..a298d0135bd4 100644 --- a/src/pages/workspace/accounting/AccountingContext.tsx +++ b/src/pages/workspace/accounting/AccountingContext.tsx @@ -69,6 +69,7 @@ function AccountingContextProvider({children, policy}: AccountingContextProvider undefined, newActiveIntegration.integrationToDisconnect, newActiveIntegration.shouldDisconnectIntegrationBeforeConnecting, + undefined, isSmallScreenWidth, ); const workspaceUpgradeNavigationDetails = accountingIntegrationData?.workspaceUpgradeNavigationDetails; From ae0804217f97a5c4b3012b40407f4bc83b651024 Mon Sep 17 00:00:00 2001 From: Yauheni Date: Wed, 16 Oct 2024 15:58:21 +0200 Subject: [PATCH 4/8] refactor code --- src/pages/workspace/accounting/AccountingContext.tsx | 2 +- src/pages/workspace/accounting/types.ts | 2 +- src/pages/workspace/accounting/utils.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/accounting/AccountingContext.tsx b/src/pages/workspace/accounting/AccountingContext.tsx index a298d0135bd4..359fa7c70c1e 100644 --- a/src/pages/workspace/accounting/AccountingContext.tsx +++ b/src/pages/workspace/accounting/AccountingContext.tsx @@ -74,7 +74,7 @@ function AccountingContextProvider({children, policy}: AccountingContextProvider ); const workspaceUpgradeNavigationDetails = accountingIntegrationData?.workspaceUpgradeNavigationDetails; if (workspaceUpgradeNavigationDetails && !isControlPolicy(policy)) { - workspaceUpgradeNavigationDetails.sideEffect?.(); + workspaceUpgradeNavigationDetails.eventBeforeNavigation?.(); Navigation.navigate( ROUTES.WORKSPACE_UPGRADE.getRoute(policyID, workspaceUpgradeNavigationDetails.integrationAlias, workspaceUpgradeNavigationDetails.backToAfterWorkspaceUpgradeRoute), diff --git a/src/pages/workspace/accounting/types.ts b/src/pages/workspace/accounting/types.ts index e05ceae1db3a..c7e392db6311 100644 --- a/src/pages/workspace/accounting/types.ts +++ b/src/pages/workspace/accounting/types.ts @@ -23,7 +23,7 @@ type WorkspaceUpgradeNavigationDetails = { /** Route to redirect to after upgrading the workspace */ backToAfterWorkspaceUpgradeRoute: string; /** Function to call after upgrading the workspace */ - sideEffect?: () => void; + eventBeforeNavigation?: () => void; }; type AccountingIntegration = { diff --git a/src/pages/workspace/accounting/utils.tsx b/src/pages/workspace/accounting/utils.tsx index 1aebb56b30b5..c2c82b15b68e 100644 --- a/src/pages/workspace/accounting/utils.tsx +++ b/src/pages/workspace/accounting/utils.tsx @@ -284,7 +284,7 @@ function getAccountingIntegrationData( subscribedAdvancedSettings: [CONST.QUICKBOOKS_DESKTOP_CONFIG.SHOULD_AUTO_CREATE_VENDOR, CONST.QUICKBOOKS_DESKTOP_CONFIG.AUTO_SYNC], workspaceUpgradeNavigationDetails: { integrationAlias: CONST.UPGRADE_FEATURE_INTRO_MAPPING.quickbooksDesktop.alias, - sideEffect: () => { + eventBeforeNavigation: () => { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing if (isSmallScreenWidth || integrationToDisconnect) { return; From 2523b49f8251493ce3cafffe7092c9ad0ae8596a Mon Sep 17 00:00:00 2001 From: Yauheni Date: Wed, 16 Oct 2024 18:15:10 +0200 Subject: [PATCH 5/8] update translates for advancedConfig --- src/languages/en.ts | 3 +-- src/languages/es.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index aad51962015c..1b8fd271982e 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2462,8 +2462,7 @@ const translations = { advancedConfig: { autoSyncDescription: 'Expensify will automatically sync with QuickBooks Desktop every day.', createEntities: 'Auto-create entities', - createEntitiesDescription: - "Expensify will automatically create vendors in QuickBooks Desktop if they don't exist already, and auto-create customers when exporting invoices.", + createEntitiesDescription: "Expensify will automatically create vendors in QuickBooks Desktop if they don't exist already.", }, }, qbo: { diff --git a/src/languages/es.ts b/src/languages/es.ts index f0eb9a13ee46..47930bfd3cf0 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2486,7 +2486,7 @@ const translations = { advancedConfig: { autoSyncDescription: 'Expensify se sincronizará automáticamente con QuickBooks Desktop todos los días.', createEntities: 'Crear entidades automáticamente', - createEntitiesDescription: 'Expensify creará automáticamente proveedores en QuickBooks Desktop si aún no existen, y creará automáticamente clientes al exportar facturas.', + createEntitiesDescription: 'Expensify creará automáticamente proveedores en QuickBooks Desktop si aún no existen.', }, }, qbo: { From 4a4334da42bd81ab59c84963af3040056e6e2d31 Mon Sep 17 00:00:00 2001 From: Yauheni Date: Wed, 16 Oct 2024 19:21:12 +0200 Subject: [PATCH 6/8] refactor code --- src/pages/workspace/accounting/AccountingContext.tsx | 2 +- src/pages/workspace/accounting/types.ts | 4 ++-- src/pages/workspace/accounting/utils.tsx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/accounting/AccountingContext.tsx b/src/pages/workspace/accounting/AccountingContext.tsx index 359fa7c70c1e..53af45473c17 100644 --- a/src/pages/workspace/accounting/AccountingContext.tsx +++ b/src/pages/workspace/accounting/AccountingContext.tsx @@ -74,7 +74,7 @@ function AccountingContextProvider({children, policy}: AccountingContextProvider ); const workspaceUpgradeNavigationDetails = accountingIntegrationData?.workspaceUpgradeNavigationDetails; if (workspaceUpgradeNavigationDetails && !isControlPolicy(policy)) { - workspaceUpgradeNavigationDetails.eventBeforeNavigation?.(); + workspaceUpgradeNavigationDetails.preNavigationEvent?.(); Navigation.navigate( ROUTES.WORKSPACE_UPGRADE.getRoute(policyID, workspaceUpgradeNavigationDetails.integrationAlias, workspaceUpgradeNavigationDetails.backToAfterWorkspaceUpgradeRoute), diff --git a/src/pages/workspace/accounting/types.ts b/src/pages/workspace/accounting/types.ts index c7e392db6311..13dad3cad1e0 100644 --- a/src/pages/workspace/accounting/types.ts +++ b/src/pages/workspace/accounting/types.ts @@ -22,8 +22,8 @@ type WorkspaceUpgradeNavigationDetails = { integrationAlias: string; /** Route to redirect to after upgrading the workspace */ backToAfterWorkspaceUpgradeRoute: string; - /** Function to call after upgrading the workspace */ - eventBeforeNavigation?: () => void; + /** Function to call before redirect */ + preNavigationEvent?: () => void; }; type AccountingIntegration = { diff --git a/src/pages/workspace/accounting/utils.tsx b/src/pages/workspace/accounting/utils.tsx index c2c82b15b68e..c524f4f6afba 100644 --- a/src/pages/workspace/accounting/utils.tsx +++ b/src/pages/workspace/accounting/utils.tsx @@ -284,7 +284,7 @@ function getAccountingIntegrationData( subscribedAdvancedSettings: [CONST.QUICKBOOKS_DESKTOP_CONFIG.SHOULD_AUTO_CREATE_VENDOR, CONST.QUICKBOOKS_DESKTOP_CONFIG.AUTO_SYNC], workspaceUpgradeNavigationDetails: { integrationAlias: CONST.UPGRADE_FEATURE_INTRO_MAPPING.quickbooksDesktop.alias, - eventBeforeNavigation: () => { + preNavigationEvent: () => { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing if (isSmallScreenWidth || integrationToDisconnect) { return; From 67485f1ca7936d0604b7e8ae875a4cc4a5ae829f Mon Sep 17 00:00:00 2001 From: Yauheni Date: Fri, 18 Oct 2024 09:05:46 +0200 Subject: [PATCH 7/8] refactor code and move enablePolicyTaxes to RequireQuickBooksDesktopModal --- .../ConnectToQuickbooksDesktopFlow/index.tsx | 3 --- .../accounting/AccountingContext.tsx | 2 -- .../qbd/QuickBooksDesktopSetupPage.tsx | 19 +++++++++++-------- src/pages/workspace/accounting/types.ts | 2 -- src/pages/workspace/accounting/utils.tsx | 8 -------- 5 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/components/ConnectToQuickbooksDesktopFlow/index.tsx b/src/components/ConnectToQuickbooksDesktopFlow/index.tsx index bf1315b452c6..07ca376a7449 100644 --- a/src/components/ConnectToQuickbooksDesktopFlow/index.tsx +++ b/src/components/ConnectToQuickbooksDesktopFlow/index.tsx @@ -1,7 +1,6 @@ import {useEffect} from 'react'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import Navigation from '@libs/Navigation/Navigation'; -import * as PolicyAction from '@userActions/Policy/Policy'; import ROUTES from '@src/ROUTES'; import type {ConnectToQuickbooksDesktopFlowProps} from './types'; @@ -12,8 +11,6 @@ function ConnectToQuickbooksDesktopFlow({policyID}: ConnectToQuickbooksDesktopFl if (isSmallScreenWidth) { Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_SETUP_REQUIRED_DEVICE_MODAL.getRoute(policyID)); } else { - // Since QBD doesn't support Taxes, we should disable them from the LHN when connecting to QBD - PolicyAction.enablePolicyTaxes(policyID, false); Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_SETUP_MODAL.getRoute(policyID)); } }, [isSmallScreenWidth, policyID]); diff --git a/src/pages/workspace/accounting/AccountingContext.tsx b/src/pages/workspace/accounting/AccountingContext.tsx index 53af45473c17..98a804d0ba66 100644 --- a/src/pages/workspace/accounting/AccountingContext.tsx +++ b/src/pages/workspace/accounting/AccountingContext.tsx @@ -74,8 +74,6 @@ function AccountingContextProvider({children, policy}: AccountingContextProvider ); const workspaceUpgradeNavigationDetails = accountingIntegrationData?.workspaceUpgradeNavigationDetails; if (workspaceUpgradeNavigationDetails && !isControlPolicy(policy)) { - workspaceUpgradeNavigationDetails.preNavigationEvent?.(); - Navigation.navigate( ROUTES.WORKSPACE_UPGRADE.getRoute(policyID, workspaceUpgradeNavigationDetails.integrationAlias, workspaceUpgradeNavigationDetails.backToAfterWorkspaceUpgradeRoute), ); diff --git a/src/pages/workspace/accounting/qbd/QuickBooksDesktopSetupPage.tsx b/src/pages/workspace/accounting/qbd/QuickBooksDesktopSetupPage.tsx index abc98f1c4d42..60a91db47395 100644 --- a/src/pages/workspace/accounting/qbd/QuickBooksDesktopSetupPage.tsx +++ b/src/pages/workspace/accounting/qbd/QuickBooksDesktopSetupPage.tsx @@ -1,4 +1,3 @@ -import type {StackScreenProps} from '@react-navigation/stack'; import React, {useEffect, useState} from 'react'; import {View} from 'react-native'; import Computer from '@assets/images/laptop-with-second-screen-sync.svg'; @@ -13,17 +12,16 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as QuickbooksDesktop from '@libs/actions/connections/QuickbooksDesktop'; import Navigation from '@libs/Navigation/Navigation'; -import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; import LoadingPage from '@pages/LoadingPage'; +import withPolicy from '@pages/workspace/withPolicy'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import * as PolicyAction from '@userActions/Policy/Policy'; import ROUTES from '@src/ROUTES'; -import type SCREENS from '@src/SCREENS'; -type RequireQuickBooksDesktopModalProps = StackScreenProps; - -function RequireQuickBooksDesktopModal({route}: RequireQuickBooksDesktopModalProps) { +function RequireQuickBooksDesktopModal({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); - const policyID: string = route.params.policyID; + const policyID = policy?.id ?? '-1'; const [isLoading, setIsLoading] = useState(true); const [codatSetupLink, setCodatSetupLink] = useState(''); @@ -36,6 +34,11 @@ function RequireQuickBooksDesktopModal({route}: RequireQuickBooksDesktopModalPro }); }; + // Since QBD doesn't support Taxes, we should disable them from the LHN when connecting to QBD + if (policy?.tax?.trackingEnabled) { + PolicyAction.enablePolicyTaxes(policyID, false); + } + fetchSetupLink(); // disabling this rule, as we want this to run only on the first render // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps @@ -85,4 +88,4 @@ function RequireQuickBooksDesktopModal({route}: RequireQuickBooksDesktopModalPro RequireQuickBooksDesktopModal.displayName = 'RequireQuickBooksDesktopModal'; -export default RequireQuickBooksDesktopModal; +export default withPolicy(RequireQuickBooksDesktopModal); diff --git a/src/pages/workspace/accounting/types.ts b/src/pages/workspace/accounting/types.ts index 13dad3cad1e0..4ff7728e5575 100644 --- a/src/pages/workspace/accounting/types.ts +++ b/src/pages/workspace/accounting/types.ts @@ -22,8 +22,6 @@ type WorkspaceUpgradeNavigationDetails = { integrationAlias: string; /** Route to redirect to after upgrading the workspace */ backToAfterWorkspaceUpgradeRoute: string; - /** Function to call before redirect */ - preNavigationEvent?: () => void; }; type AccountingIntegration = { diff --git a/src/pages/workspace/accounting/utils.tsx b/src/pages/workspace/accounting/utils.tsx index c524f4f6afba..b106a3ca5a89 100644 --- a/src/pages/workspace/accounting/utils.tsx +++ b/src/pages/workspace/accounting/utils.tsx @@ -15,7 +15,6 @@ import {canUseTaxNetSuite} from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; import type {ThemeStyles} from '@styles/index'; import {getTrackingCategories} from '@userActions/connections/Xero'; -import * as PolicyAction from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import type {Policy} from '@src/types/onyx'; @@ -284,13 +283,6 @@ function getAccountingIntegrationData( subscribedAdvancedSettings: [CONST.QUICKBOOKS_DESKTOP_CONFIG.SHOULD_AUTO_CREATE_VENDOR, CONST.QUICKBOOKS_DESKTOP_CONFIG.AUTO_SYNC], workspaceUpgradeNavigationDetails: { integrationAlias: CONST.UPGRADE_FEATURE_INTRO_MAPPING.quickbooksDesktop.alias, - preNavigationEvent: () => { - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - if (isSmallScreenWidth || integrationToDisconnect) { - return; - } - PolicyAction.enablePolicyTaxes(policyID, false); - }, backToAfterWorkspaceUpgradeRoute: getBackToAfterWorkspaceUpgradeRouteForQBD(), }, }; From 55555828c7f28ee06a36d69d30d9c027b3ed84b5 Mon Sep 17 00:00:00 2001 From: Yauheni Date: Fri, 18 Oct 2024 15:49:49 +0200 Subject: [PATCH 8/8] remove condition for enablePolicyTaxes --- .../qbd/QuickBooksDesktopSetupPage.tsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/pages/workspace/accounting/qbd/QuickBooksDesktopSetupPage.tsx b/src/pages/workspace/accounting/qbd/QuickBooksDesktopSetupPage.tsx index 60a91db47395..1aa80231fc7d 100644 --- a/src/pages/workspace/accounting/qbd/QuickBooksDesktopSetupPage.tsx +++ b/src/pages/workspace/accounting/qbd/QuickBooksDesktopSetupPage.tsx @@ -1,3 +1,4 @@ +import type {StackScreenProps} from '@react-navigation/stack'; import React, {useEffect, useState} from 'react'; import {View} from 'react-native'; import Computer from '@assets/images/laptop-with-second-screen-sync.svg'; @@ -12,16 +13,18 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as QuickbooksDesktop from '@libs/actions/connections/QuickbooksDesktop'; import Navigation from '@libs/Navigation/Navigation'; +import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; import LoadingPage from '@pages/LoadingPage'; -import withPolicy from '@pages/workspace/withPolicy'; -import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import * as PolicyAction from '@userActions/Policy/Policy'; import ROUTES from '@src/ROUTES'; +import type SCREENS from '@src/SCREENS'; -function RequireQuickBooksDesktopModal({policy}: WithPolicyProps) { +type RequireQuickBooksDesktopModalProps = StackScreenProps; + +function RequireQuickBooksDesktopModal({route}: RequireQuickBooksDesktopModalProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); - const policyID = policy?.id ?? '-1'; + const policyID: string = route.params.policyID; const [isLoading, setIsLoading] = useState(true); const [codatSetupLink, setCodatSetupLink] = useState(''); @@ -35,9 +38,7 @@ function RequireQuickBooksDesktopModal({policy}: WithPolicyProps) { }; // Since QBD doesn't support Taxes, we should disable them from the LHN when connecting to QBD - if (policy?.tax?.trackingEnabled) { - PolicyAction.enablePolicyTaxes(policyID, false); - } + PolicyAction.enablePolicyTaxes(policyID, false); fetchSetupLink(); // disabling this rule, as we want this to run only on the first render @@ -88,4 +89,4 @@ function RequireQuickBooksDesktopModal({policy}: WithPolicyProps) { RequireQuickBooksDesktopModal.displayName = 'RequireQuickBooksDesktopModal'; -export default withPolicy(RequireQuickBooksDesktopModal); +export default RequireQuickBooksDesktopModal;