From 189c4f4df13f15db503fb45f8bf2b54c489dd8d0 Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Fri, 3 May 2024 14:19:58 +0530
Subject: [PATCH 1/8] Add sync functionality in Xero connection

---
 .../actions/connections/QuickBooksOnline.ts   | 39 +++----------------
 src/libs/actions/connections/index.ts         | 35 ++++++++++++++++-
 .../accounting/PolicyAccountingPage.tsx       |  4 +-
 3 files changed, 41 insertions(+), 37 deletions(-)

diff --git a/src/libs/actions/connections/QuickBooksOnline.ts b/src/libs/actions/connections/QuickBooksOnline.ts
index f507758e8d38..3bf4bb4b6a36 100644
--- a/src/libs/actions/connections/QuickBooksOnline.ts
+++ b/src/libs/actions/connections/QuickBooksOnline.ts
@@ -1,41 +1,14 @@
-import type {OnyxUpdate} from 'react-native-onyx';
-import Onyx from 'react-native-onyx';
-import * as API from '@libs/API';
-import type {ConnectPolicyToAccountingIntegrationParams, SyncPolicyToQuickbooksOnlineParams} from '@libs/API/parameters';
+import type {ConnectPolicyToAccountingIntegrationParams} from '@libs/API/parameters';
 import {READ_COMMANDS} from '@libs/API/types';
 import {getCommandURL} from '@libs/ApiUtils';
-import CONST from '@src/CONST';
-import ONYXKEYS from '@src/ONYXKEYS';
 
 function getQuickBooksOnlineSetupLink(policyID: string) {
     const params: ConnectPolicyToAccountingIntegrationParams = {policyID};
-    const commandURL = getCommandURL({command: READ_COMMANDS.CONNECT_POLICY_TO_QUICKBOOKS_ONLINE, shouldSkipWebProxy: true});
+    const commandURL = getCommandURL({
+        command: READ_COMMANDS.CONNECT_POLICY_TO_QUICKBOOKS_ONLINE,
+        shouldSkipWebProxy: true,
+    });
     return commandURL + new URLSearchParams(params).toString();
 }
 
-function syncConnection(policyID: string) {
-    const optimisticData: OnyxUpdate[] = [
-        {
-            onyxMethod: Onyx.METHOD.MERGE,
-            key: `${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policyID}`,
-            value: {
-                stageInProgress: CONST.POLICY.CONNECTIONS.SYNC_STAGE_NAME.STARTING_IMPORT,
-                connectionName: CONST.POLICY.CONNECTIONS.NAME.QBO,
-            },
-        },
-    ];
-    const failureData: OnyxUpdate[] = [
-        {
-            onyxMethod: Onyx.METHOD.SET,
-            key: `${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policyID}`,
-            value: null,
-        },
-    ];
-    const parameters: SyncPolicyToQuickbooksOnlineParams = {
-        policyID,
-        idempotencyKey: policyID,
-    };
-    API.read(READ_COMMANDS.SYNC_POLICY_TO_QUICKBOOKS_ONLINE, parameters, {optimisticData, failureData});
-}
-
-export {getQuickBooksOnlineSetupLink, syncConnection};
+export {getQuickBooksOnlineSetupLink};
diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts
index 5ce806c7d4be..ca09f1069b72 100644
--- a/src/libs/actions/connections/index.ts
+++ b/src/libs/actions/connections/index.ts
@@ -2,7 +2,8 @@ import Onyx from 'react-native-onyx';
 import type {OnyxUpdate} from 'react-native-onyx';
 import * as API from '@libs/API';
 import type {RemovePolicyConnectionParams, UpdatePolicyConnectionConfigParams} from '@libs/API/parameters';
-import {WRITE_COMMANDS} from '@libs/API/types';
+import {SyncPolicyToQuickbooksOnlineParams} from '@libs/API/parameters';
+import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types';
 import * as ErrorUtils from '@libs/ErrorUtils';
 import CONST from '@src/CONST';
 import ONYXKEYS from '@src/ONYXKEYS';
@@ -124,4 +125,34 @@ function updatePolicyConnectionConfig<TConnectionName extends ConnectionName, TS
     API.write(WRITE_COMMANDS.UPDATE_POLICY_CONNECTION_CONFIG, parameters, {optimisticData, failureData, successData});
 }
 
-export {removePolicyConnection, updatePolicyConnectionConfig};
+function syncConnection(policyID: string, connectionName: string) {
+    const optimisticData: OnyxUpdate[] = [
+        {
+            onyxMethod: Onyx.METHOD.MERGE,
+            key: `${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policyID}`,
+            value: {
+                stageInProgress: CONST.POLICY.CONNECTIONS.SYNC_STAGE_NAME.STARTING_IMPORT,
+                connectionName: connectionName,
+            },
+        },
+    ];
+    const failureData: OnyxUpdate[] = [
+        {
+            onyxMethod: Onyx.METHOD.SET,
+            key: `${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policyID}`,
+            value: null,
+        },
+    ];
+    const parameters: SyncPolicyToQuickbooksOnlineParams = {
+        policyID,
+        idempotencyKey: policyID,
+    };
+
+    if (connectionName === CONST.POLICY.CONNECTIONS.NAME.QBO) {
+        API.read(READ_COMMANDS.SYNC_POLICY_TO_QUICKBOOKS_ONLINE, parameters, {optimisticData, failureData});
+    } else if (connectionName === CONST.POLICY.CONNECTIONS.NAME.XERO) {
+        // Update this when SYNC_POLICY_TO_XERO is available
+    }
+}
+
+export {removePolicyConnection, updatePolicyConnectionConfig, syncConnection};
diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx
index 87bede34f3cb..50deefdf94b8 100644
--- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx
+++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx
@@ -24,7 +24,7 @@ import useTheme from '@hooks/useTheme';
 import useThemeStyles from '@hooks/useThemeStyles';
 import useWindowDimensions from '@hooks/useWindowDimensions';
 import {removePolicyConnection} from '@libs/actions/connections';
-import {syncConnection} from '@libs/actions/connections/QuickBooksOnline';
+import {syncConnection} from '@libs/actions/connections';
 import {findCurrentXeroOrganization, getXeroTenants} from '@libs/PolicyUtils';
 import Navigation from '@navigation/Navigation';
 import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
@@ -128,7 +128,7 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting
             {
                 icon: Expensicons.Sync,
                 text: translate('workspace.accounting.syncNow'),
-                onSelected: () => syncConnection(policyID),
+                onSelected: () => syncConnection(policyID, connectedIntegration),
                 disabled: isOffline,
             },
             {

From a362c38c92af0a5af95be66f5c22ab0df149037c Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Fri, 3 May 2024 17:36:18 +0530
Subject: [PATCH 2/8] Update

---
 .../ConnectToQuickbooksOnlineButton/index.native.tsx       | 2 +-
 src/components/ConnectToQuickbooksOnlineButton/index.tsx   | 2 +-
 src/libs/actions/connections/QuickBooksOnline.ts           | 2 +-
 src/libs/actions/connections/index.ts                      | 7 +++----
 4 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/components/ConnectToQuickbooksOnlineButton/index.native.tsx b/src/components/ConnectToQuickbooksOnlineButton/index.native.tsx
index 3a5e545cce88..50f71ea5a1ae 100644
--- a/src/components/ConnectToQuickbooksOnlineButton/index.native.tsx
+++ b/src/components/ConnectToQuickbooksOnlineButton/index.native.tsx
@@ -10,7 +10,7 @@ import HeaderWithBackButton from '@components/HeaderWithBackButton';
 import Modal from '@components/Modal';
 import useLocalize from '@hooks/useLocalize';
 import {removePolicyConnection} from '@libs/actions/connections';
-import {getQuickBooksOnlineSetupLink} from '@libs/actions/connections/QuickBooksOnline';
+import getQuickBooksOnlineSetupLink from '@libs/actions/connections/QuickBooksOnline';
 import CONST from '@src/CONST';
 import ONYXKEYS from '@src/ONYXKEYS';
 import type {Session} from '@src/types/onyx';
diff --git a/src/components/ConnectToQuickbooksOnlineButton/index.tsx b/src/components/ConnectToQuickbooksOnlineButton/index.tsx
index 7de2ba55fb84..b17ff374d3a6 100644
--- a/src/components/ConnectToQuickbooksOnlineButton/index.tsx
+++ b/src/components/ConnectToQuickbooksOnlineButton/index.tsx
@@ -5,7 +5,7 @@ import useEnvironment from '@hooks/useEnvironment';
 import useLocalize from '@hooks/useLocalize';
 import useThemeStyles from '@hooks/useThemeStyles';
 import {removePolicyConnection} from '@libs/actions/connections';
-import {getQuickBooksOnlineSetupLink} from '@libs/actions/connections/QuickBooksOnline';
+import getQuickBooksOnlineSetupLink from '@libs/actions/connections/QuickBooksOnline';
 import * as Link from '@userActions/Link';
 import CONST from '@src/CONST';
 import type {ConnectToQuickbooksOnlineButtonProps} from './types';
diff --git a/src/libs/actions/connections/QuickBooksOnline.ts b/src/libs/actions/connections/QuickBooksOnline.ts
index 3bf4bb4b6a36..2642ad4056a9 100644
--- a/src/libs/actions/connections/QuickBooksOnline.ts
+++ b/src/libs/actions/connections/QuickBooksOnline.ts
@@ -11,4 +11,4 @@ function getQuickBooksOnlineSetupLink(policyID: string) {
     return commandURL + new URLSearchParams(params).toString();
 }
 
-export {getQuickBooksOnlineSetupLink};
+export default getQuickBooksOnlineSetupLink;
diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts
index ca09f1069b72..2296ae28df60 100644
--- a/src/libs/actions/connections/index.ts
+++ b/src/libs/actions/connections/index.ts
@@ -1,8 +1,7 @@
 import Onyx from 'react-native-onyx';
 import type {OnyxUpdate} from 'react-native-onyx';
 import * as API from '@libs/API';
-import type {RemovePolicyConnectionParams, UpdatePolicyConnectionConfigParams} from '@libs/API/parameters';
-import {SyncPolicyToQuickbooksOnlineParams} from '@libs/API/parameters';
+import type {RemovePolicyConnectionParams, UpdatePolicyConnectionConfigParams, SyncPolicyToQuickbooksOnlineParams} from '@libs/API/parameters';
 import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types';
 import * as ErrorUtils from '@libs/ErrorUtils';
 import CONST from '@src/CONST';
@@ -125,14 +124,14 @@ function updatePolicyConnectionConfig<TConnectionName extends ConnectionName, TS
     API.write(WRITE_COMMANDS.UPDATE_POLICY_CONNECTION_CONFIG, parameters, {optimisticData, failureData, successData});
 }
 
-function syncConnection(policyID: string, connectionName: string) {
+function syncConnection(policyID: string, connectionName: PolicyConnectionName | undefined) {
     const optimisticData: OnyxUpdate[] = [
         {
             onyxMethod: Onyx.METHOD.MERGE,
             key: `${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policyID}`,
             value: {
                 stageInProgress: CONST.POLICY.CONNECTIONS.SYNC_STAGE_NAME.STARTING_IMPORT,
-                connectionName: connectionName,
+                connectionName,
             },
         },
     ];

From d7fc0c3c0cbd8945bc763fdf082760c1808edab0 Mon Sep 17 00:00:00 2001
From: Shridhar Goel <35566748+ShridharGoel@users.noreply.github.com>
Date: Fri, 3 May 2024 17:54:54 +0530
Subject: [PATCH 3/8] Update PolicyAccountingPage.tsx

---
 src/pages/workspace/accounting/PolicyAccountingPage.tsx | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx
index 50deefdf94b8..51d9bb493728 100644
--- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx
+++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx
@@ -23,8 +23,7 @@ import usePermissions from '@hooks/usePermissions';
 import useTheme from '@hooks/useTheme';
 import useThemeStyles from '@hooks/useThemeStyles';
 import useWindowDimensions from '@hooks/useWindowDimensions';
-import {removePolicyConnection} from '@libs/actions/connections';
-import {syncConnection} from '@libs/actions/connections';
+import {removePolicyConnection, syncConnection} from '@libs/actions/connections';
 import {findCurrentXeroOrganization, getXeroTenants} from '@libs/PolicyUtils';
 import Navigation from '@navigation/Navigation';
 import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';

From ff31b5350e3b2f06368fe96e26189a1432dac295 Mon Sep 17 00:00:00 2001
From: Shridhar Goel <35566748+ShridharGoel@users.noreply.github.com>
Date: Fri, 3 May 2024 17:55:24 +0530
Subject: [PATCH 4/8] Update PolicyAccountingPage.tsx

---
 src/pages/workspace/accounting/PolicyAccountingPage.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx
index 51d9bb493728..9541021c79cb 100644
--- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx
+++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx
@@ -136,7 +136,7 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting
                 onSelected: () => setIsDisconnectModalOpen(true),
             },
         ],
-        [translate, policyID, isOffline],
+        [translate, policyID, isOffline, connectedIntegration],
     );
 
     const connectionsMenuItems: MenuItemProps[] = useMemo(() => {

From 1ddad046d5340f77b254c8c827687c8299cc537f Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Wed, 8 May 2024 18:37:05 +0530
Subject: [PATCH 5/8] Add new command and JSdoc

---
 .../SyncPolicyToIntegratedConnectionParams.ts |  6 +++++
 .../SyncPolicyToQuickbooksOnlineParams.ts     |  6 -----
 src/libs/API/parameters/index.ts              |  2 +-
 src/libs/API/types.ts                         |  4 ++-
 src/libs/actions/connections/index.ts         | 26 +++++++++++++------
 5 files changed, 28 insertions(+), 16 deletions(-)
 create mode 100644 src/libs/API/parameters/SyncPolicyToIntegratedConnectionParams.ts
 delete mode 100644 src/libs/API/parameters/SyncPolicyToQuickbooksOnlineParams.ts

diff --git a/src/libs/API/parameters/SyncPolicyToIntegratedConnectionParams.ts b/src/libs/API/parameters/SyncPolicyToIntegratedConnectionParams.ts
new file mode 100644
index 000000000000..ad3a926c6b3e
--- /dev/null
+++ b/src/libs/API/parameters/SyncPolicyToIntegratedConnectionParams.ts
@@ -0,0 +1,6 @@
+type SyncPolicyToIntegratedConnectionParams = {
+    policyID: string;
+    idempotencyKey: string;
+};
+
+export default SyncPolicyToIntegratedConnectionParams;
diff --git a/src/libs/API/parameters/SyncPolicyToQuickbooksOnlineParams.ts b/src/libs/API/parameters/SyncPolicyToQuickbooksOnlineParams.ts
deleted file mode 100644
index b5782c150b9f..000000000000
--- a/src/libs/API/parameters/SyncPolicyToQuickbooksOnlineParams.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-type SyncPolicyToQuickbooksOnlineParams = {
-    policyID: string;
-    idempotencyKey: string;
-};
-
-export default SyncPolicyToQuickbooksOnlineParams;
diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts
index 30261051c0e5..6fa8cf510eb0 100644
--- a/src/libs/API/parameters/index.ts
+++ b/src/libs/API/parameters/index.ts
@@ -12,7 +12,7 @@ export type {default as BeginSignInParams} from './BeginSignInParams';
 export type {default as CloseAccountParams} from './CloseAccountParams';
 export type {default as ConnectBankAccountParams} from './ConnectBankAccountParams';
 export type {default as ConnectPolicyToAccountingIntegrationParams} from './ConnectPolicyToAccountingIntegrationParams';
-export type {default as SyncPolicyToQuickbooksOnlineParams} from './SyncPolicyToQuickbooksOnlineParams';
+export type {default as SyncPolicyToIntegratedConnectionParams} from './SyncPolicyToIntegratedConnectionParams';
 export type {default as DeleteContactMethodParams} from './DeleteContactMethodParams';
 export type {default as DeletePaymentBankAccountParams} from './DeletePaymentBankAccountParams';
 export type {default as DeletePaymentCardParams} from './DeletePaymentCardParams';
diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts
index cd85cdfbe401..ee2639284883 100644
--- a/src/libs/API/types.ts
+++ b/src/libs/API/types.ts
@@ -434,6 +434,7 @@ const READ_COMMANDS = {
     CONNECT_POLICY_TO_QUICKBOOKS_ONLINE: 'ConnectPolicyToQuickbooksOnline',
     CONNECT_POLICY_TO_XERO: 'ConnectPolicyToXero',
     SYNC_POLICY_TO_QUICKBOOKS_ONLINE: 'SyncPolicyToQuickbooksOnline',
+    SYNC_POLICY_TO_XERO: 'SyncPolicyToXero',
     OPEN_REIMBURSEMENT_ACCOUNT_PAGE: 'OpenReimbursementAccountPage',
     OPEN_WORKSPACE_VIEW: 'OpenWorkspaceView',
     GET_MAPBOX_ACCESS_TOKEN: 'GetMapboxAccessToken',
@@ -479,7 +480,8 @@ type ReadCommand = ValueOf<typeof READ_COMMANDS>;
 type ReadCommandParameters = {
     [READ_COMMANDS.CONNECT_POLICY_TO_QUICKBOOKS_ONLINE]: Parameters.ConnectPolicyToAccountingIntegrationParams;
     [READ_COMMANDS.CONNECT_POLICY_TO_XERO]: Parameters.ConnectPolicyToAccountingIntegrationParams;
-    [READ_COMMANDS.SYNC_POLICY_TO_QUICKBOOKS_ONLINE]: Parameters.SyncPolicyToQuickbooksOnlineParams;
+    [READ_COMMANDS.SYNC_POLICY_TO_QUICKBOOKS_ONLINE]: Parameters.SyncPolicyToIntegratedConnectionParams;
+    [READ_COMMANDS.SYNC_POLICY_TO_XERO]: Parameters.SyncPolicyToIntegratedConnectionParams;
     [READ_COMMANDS.OPEN_REIMBURSEMENT_ACCOUNT_PAGE]: Parameters.OpenReimbursementAccountPageParams;
     [READ_COMMANDS.OPEN_WORKSPACE_VIEW]: Parameters.OpenWorkspaceViewParams;
     [READ_COMMANDS.GET_MAPBOX_ACCESS_TOKEN]: EmptyObject;
diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts
index 2296ae28df60..10d07599c374 100644
--- a/src/libs/actions/connections/index.ts
+++ b/src/libs/actions/connections/index.ts
@@ -1,7 +1,11 @@
-import Onyx from 'react-native-onyx';
 import type {OnyxUpdate} from 'react-native-onyx';
+import Onyx from 'react-native-onyx';
 import * as API from '@libs/API';
-import type {RemovePolicyConnectionParams, UpdatePolicyConnectionConfigParams, SyncPolicyToQuickbooksOnlineParams} from '@libs/API/parameters';
+import type {
+    RemovePolicyConnectionParams,
+    SyncPolicyToIntegratedConnectionParams,
+    UpdatePolicyConnectionConfigParams
+} from '@libs/API/parameters';
 import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types';
 import * as ErrorUtils from '@libs/ErrorUtils';
 import CONST from '@src/CONST';
@@ -42,6 +46,7 @@ function removePolicyConnection(policyID: string, connectionName: PolicyConnecti
     };
     API.write(WRITE_COMMANDS.REMOVE_POLICY_CONNECTION, parameters, {optimisticData, failureData});
 }
+
 function updatePolicyConnectionConfig<TConnectionName extends ConnectionName, TSettingName extends keyof Connections[TConnectionName]['config']>(
     policyID: string,
     connectionName: TConnectionName,
@@ -124,6 +129,12 @@ function updatePolicyConnectionConfig<TConnectionName extends ConnectionName, TS
     API.write(WRITE_COMMANDS.UPDATE_POLICY_CONNECTION_CONFIG, parameters, {optimisticData, failureData, successData});
 }
 
+/**
+ * This method helps in syncing policy to the connected accounting integration.
+ *
+ * @param policyID - ID of the policy for which the sync is needed
+ * @param connectionName - Name of the connection, QBO/Xero
+ */
 function syncConnection(policyID: string, connectionName: PolicyConnectionName | undefined) {
     const optimisticData: OnyxUpdate[] = [
         {
@@ -142,16 +153,15 @@ function syncConnection(policyID: string, connectionName: PolicyConnectionName |
             value: null,
         },
     ];
-    const parameters: SyncPolicyToQuickbooksOnlineParams = {
+    const parameters: SyncPolicyToIntegratedConnectionParams = {
         policyID,
         idempotencyKey: policyID,
     };
 
-    if (connectionName === CONST.POLICY.CONNECTIONS.NAME.QBO) {
-        API.read(READ_COMMANDS.SYNC_POLICY_TO_QUICKBOOKS_ONLINE, parameters, {optimisticData, failureData});
-    } else if (connectionName === CONST.POLICY.CONNECTIONS.NAME.XERO) {
-        // Update this when SYNC_POLICY_TO_XERO is available
-    }
+    API.read(connectionName === CONST.POLICY.CONNECTIONS.NAME.QBO ? READ_COMMANDS.SYNC_POLICY_TO_QUICKBOOKS_ONLINE : READ_COMMANDS.SYNC_POLICY_TO_XERO, parameters, {
+        optimisticData,
+        failureData
+    });
 }
 
 export {removePolicyConnection, updatePolicyConnectionConfig, syncConnection};

From b6fa1937cc2563d8a1b64c1b91ec9aa20773ce61 Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Fri, 10 May 2024 01:52:47 +0530
Subject: [PATCH 6/8] Update

---
 src/libs/actions/connections/index.ts | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts
index 7b77f785bb6a..95495b19d7c7 100644
--- a/src/libs/actions/connections/index.ts
+++ b/src/libs/actions/connections/index.ts
@@ -1,11 +1,7 @@
 import type {OnyxUpdate} from 'react-native-onyx';
 import Onyx from 'react-native-onyx';
 import * as API from '@libs/API';
-import type {
-    RemovePolicyConnectionParams,
-    SyncPolicyToIntegratedConnectionParams,
-    UpdatePolicyConnectionConfigParams
-} from '@libs/API/parameters';
+import type {RemovePolicyConnectionParams, SyncPolicyToIntegratedConnectionParams, UpdatePolicyConnectionConfigParams} from '@libs/API/parameters';
 import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types';
 import * as ErrorUtils from '@libs/ErrorUtils';
 import CONST from '@src/CONST';
@@ -150,7 +146,7 @@ function syncConnection(policyID: string, connectionName: PolicyConnectionName |
 
     API.read(connectionName === CONST.POLICY.CONNECTIONS.NAME.QBO ? READ_COMMANDS.SYNC_POLICY_TO_QUICKBOOKS_ONLINE : READ_COMMANDS.SYNC_POLICY_TO_XERO, parameters, {
         optimisticData,
-        failureData
+        failureData,
     });
 }
 

From 1a4bb31132a734320abc24d5eee2cd1f46ff910f Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Tue, 14 May 2024 20:06:41 +0530
Subject: [PATCH 7/8] Updates

---
 .../SyncPolicyToIntegratedConnectionParams.ts   |  6 ------
 .../SyncPolicyToQuickbooksOnlineParams.ts       |  6 ++++++
 src/libs/API/parameters/index.ts                |  3 ++-
 src/libs/API/types.ts                           |  4 ++--
 src/libs/actions/connections/index.ts           | 17 ++++++++++++-----
 5 files changed, 22 insertions(+), 14 deletions(-)
 delete mode 100644 src/libs/API/parameters/SyncPolicyToIntegratedConnectionParams.ts
 create mode 100644 src/libs/API/parameters/SyncPolicyToQuickbooksOnlineParams.ts

diff --git a/src/libs/API/parameters/SyncPolicyToIntegratedConnectionParams.ts b/src/libs/API/parameters/SyncPolicyToIntegratedConnectionParams.ts
deleted file mode 100644
index ad3a926c6b3e..000000000000
--- a/src/libs/API/parameters/SyncPolicyToIntegratedConnectionParams.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-type SyncPolicyToIntegratedConnectionParams = {
-    policyID: string;
-    idempotencyKey: string;
-};
-
-export default SyncPolicyToIntegratedConnectionParams;
diff --git a/src/libs/API/parameters/SyncPolicyToQuickbooksOnlineParams.ts b/src/libs/API/parameters/SyncPolicyToQuickbooksOnlineParams.ts
new file mode 100644
index 000000000000..b5782c150b9f
--- /dev/null
+++ b/src/libs/API/parameters/SyncPolicyToQuickbooksOnlineParams.ts
@@ -0,0 +1,6 @@
+type SyncPolicyToQuickbooksOnlineParams = {
+    policyID: string;
+    idempotencyKey: string;
+};
+
+export default SyncPolicyToQuickbooksOnlineParams;
diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts
index 34609b6a40ec..55acc24f3ed3 100644
--- a/src/libs/API/parameters/index.ts
+++ b/src/libs/API/parameters/index.ts
@@ -12,7 +12,8 @@ export type {default as BeginSignInParams} from './BeginSignInParams';
 export type {default as CloseAccountParams} from './CloseAccountParams';
 export type {default as ConnectBankAccountParams} from './ConnectBankAccountParams';
 export type {default as ConnectPolicyToAccountingIntegrationParams} from './ConnectPolicyToAccountingIntegrationParams';
-export type {default as SyncPolicyToIntegratedConnectionParams} from './SyncPolicyToIntegratedConnectionParams';
+export type {default as SyncPolicyToQuickbooksOnlineParams} from './SyncPolicyToQuickbooksOnlineParams';
+export type {default as SyncPolicyToXeroParams} from './SyncPolicyToXeroParams';
 export type {default as DeleteContactMethodParams} from './DeleteContactMethodParams';
 export type {default as DeletePaymentBankAccountParams} from './DeletePaymentBankAccountParams';
 export type {default as DeletePaymentCardParams} from './DeletePaymentCardParams';
diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts
index 329ac4294b96..e6c3644f7278 100644
--- a/src/libs/API/types.ts
+++ b/src/libs/API/types.ts
@@ -486,8 +486,8 @@ type ReadCommand = ValueOf<typeof READ_COMMANDS>;
 type ReadCommandParameters = {
     [READ_COMMANDS.CONNECT_POLICY_TO_QUICKBOOKS_ONLINE]: Parameters.ConnectPolicyToAccountingIntegrationParams;
     [READ_COMMANDS.CONNECT_POLICY_TO_XERO]: Parameters.ConnectPolicyToAccountingIntegrationParams;
-    [READ_COMMANDS.SYNC_POLICY_TO_QUICKBOOKS_ONLINE]: Parameters.SyncPolicyToIntegratedConnectionParams;
-    [READ_COMMANDS.SYNC_POLICY_TO_XERO]: Parameters.SyncPolicyToIntegratedConnectionParams;
+    [READ_COMMANDS.SYNC_POLICY_TO_QUICKBOOKS_ONLINE]: Parameters.SyncPolicyToQuickbooksOnlineParams;
+    [READ_COMMANDS.SYNC_POLICY_TO_XERO]: Parameters.SyncPolicyToXeroParams;
     [READ_COMMANDS.OPEN_REIMBURSEMENT_ACCOUNT_PAGE]: Parameters.OpenReimbursementAccountPageParams;
     [READ_COMMANDS.OPEN_WORKSPACE_VIEW]: Parameters.OpenWorkspaceViewParams;
     [READ_COMMANDS.GET_MAPBOX_ACCESS_TOKEN]: EmptyObject;
diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts
index 95495b19d7c7..8bbdd557bb4d 100644
--- a/src/libs/actions/connections/index.ts
+++ b/src/libs/actions/connections/index.ts
@@ -1,7 +1,7 @@
 import type {OnyxUpdate} from 'react-native-onyx';
 import Onyx from 'react-native-onyx';
 import * as API from '@libs/API';
-import type {RemovePolicyConnectionParams, SyncPolicyToIntegratedConnectionParams, UpdatePolicyConnectionConfigParams} from '@libs/API/parameters';
+import type {RemovePolicyConnectionParams, SyncPolicyToQuickbooksOnlineParams, SyncPolicyToXeroParams, UpdatePolicyConnectionConfigParams} from '@libs/API/parameters';
 import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types';
 import * as ErrorUtils from '@libs/ErrorUtils';
 import CONST from '@src/CONST';
@@ -139,10 +139,17 @@ function syncConnection(policyID: string, connectionName: PolicyConnectionName |
             value: null,
         },
     ];
-    const parameters: SyncPolicyToIntegratedConnectionParams = {
-        policyID,
-        idempotencyKey: policyID,
-    };
+
+    const parameters: SyncPolicyToQuickbooksOnlineParams | SyncPolicyToXeroParams =
+        connectionName === CONST.POLICY.CONNECTIONS.NAME.QBO
+            ? ({
+                  policyID,
+                  idempotencyKey: policyID,
+              } as SyncPolicyToQuickbooksOnlineParams)
+            : ({
+                  policyID,
+                  idempotencyKey: policyID,
+              } as SyncPolicyToXeroParams);
 
     API.read(connectionName === CONST.POLICY.CONNECTIONS.NAME.QBO ? READ_COMMANDS.SYNC_POLICY_TO_QUICKBOOKS_ONLINE : READ_COMMANDS.SYNC_POLICY_TO_XERO, parameters, {
         optimisticData,

From e2f0a629fc2bcbef80f0a95bd3817b4969a9b965 Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Fri, 17 May 2024 01:29:33 +0530
Subject: [PATCH 8/8] Fix lint

---
 src/libs/actions/connections/index.ts | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts
index 1093ecaeba7a..8fd406f13231 100644
--- a/src/libs/actions/connections/index.ts
+++ b/src/libs/actions/connections/index.ts
@@ -1,7 +1,13 @@
 import type {OnyxUpdate} from 'react-native-onyx';
 import Onyx from 'react-native-onyx';
 import * as API from '@libs/API';
-import type {RemovePolicyConnectionParams, SyncPolicyToQuickbooksOnlineParams, SyncPolicyToXeroParams, UpdatePolicyConnectionConfigParams, UpdateManyPolicyConnectionConfigurationsParams} from '@libs/API/parameters';
+import type {
+    RemovePolicyConnectionParams,
+    SyncPolicyToQuickbooksOnlineParams,
+    SyncPolicyToXeroParams,
+    UpdateManyPolicyConnectionConfigurationsParams,
+    UpdatePolicyConnectionConfigParams,
+} from '@libs/API/parameters';
 import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types';
 import * as ErrorUtils from '@libs/ErrorUtils';
 import CONST from '@src/CONST';
