From 5bd8959925ca2aa7b05f2a012d094d288f5f7f87 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Fri, 24 May 2024 16:47:31 -0700 Subject: [PATCH 1/9] fix: the logic to check if there is an accounting connection --- src/libs/PolicyUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 0343fa0b2c56..0eec003ba166 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -290,7 +290,7 @@ function extractPolicyIDFromPath(path: string) { * Whether the policy has active accounting integration connections */ function hasAccountingConnections(policy: OnyxEntry) { - return Boolean(policy?.connections); + return Object.keys(policy?.connections ?? {}).length !== 0; } function getPathWithoutPolicyID(path: string) { From f7281db566133c9c07f1a6f7b290dd97b2922b18 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Fri, 24 May 2024 16:54:17 -0700 Subject: [PATCH 2/9] chore: use the util function to check if there is an accounting connection --- src/pages/workspace/tags/WorkspaceTagsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/tags/WorkspaceTagsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsPage.tsx index 64e9a661cd27..960056b14a96 100644 --- a/src/pages/workspace/tags/WorkspaceTagsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsPage.tsx @@ -172,7 +172,7 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) { const isLoading = !isOffline && policyTags === undefined; const getHeaderButtons = () => { - const isThereAnyAccountingConnection = Object.keys(policy?.connections ?? {}).length !== 0; + const isThereAnyAccountingConnection = PolicyUtils.hasAccountingConnections(policy); if (selectedTagsArray.length === 0) { return ( From 307a3611467b5116d87ff2ea7f8986e001a4010d Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Fri, 24 May 2024 16:54:50 -0700 Subject: [PATCH 3/9] refactor: rename a boolean variable --- src/pages/workspace/tags/WorkspaceTagsPage.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/tags/WorkspaceTagsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsPage.tsx index 960056b14a96..75bdea1629ca 100644 --- a/src/pages/workspace/tags/WorkspaceTagsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsPage.tsx @@ -172,12 +172,12 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) { const isLoading = !isOffline && policyTags === undefined; const getHeaderButtons = () => { - const isThereAnyAccountingConnection = PolicyUtils.hasAccountingConnections(policy); + const hasAccountingConnections = PolicyUtils.hasAccountingConnections(policy); if (selectedTagsArray.length === 0) { return ( - {!isThereAnyAccountingConnection && !isMultiLevelTags && ( + {!hasAccountingConnections && !isMultiLevelTags && (