From 409e89805a0556fff8e130fcc9b2bd74d1d7d49b Mon Sep 17 00:00:00 2001 From: Rayane <77965000+rayane-d@users.noreply.github.com> Date: Mon, 14 Sep 2026 00:32:51 +0100 Subject: [PATCH 1/3] Send domainAccountID when setting card feed transaction liability --- src/libs/API/parameters/SetCompanyCardTransactionLiability.ts | 2 ++ src/libs/actions/CompanyCards.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/src/libs/API/parameters/SetCompanyCardTransactionLiability.ts b/src/libs/API/parameters/SetCompanyCardTransactionLiability.ts index 92b7af078dd7..650eeb962fbd 100644 --- a/src/libs/API/parameters/SetCompanyCardTransactionLiability.ts +++ b/src/libs/API/parameters/SetCompanyCardTransactionLiability.ts @@ -1,5 +1,7 @@ type SetCompanyCardTransactionLiability = { + policyID: string; bankName: string; + domainAccountID: number; liabilityType: string; }; diff --git a/src/libs/actions/CompanyCards.ts b/src/libs/actions/CompanyCards.ts index 9beb936e2240..73d681ef1fd5 100644 --- a/src/libs/actions/CompanyCards.ts +++ b/src/libs/actions/CompanyCards.ts @@ -345,6 +345,7 @@ function setWorkspaceCompanyCardTransactionLiability(domainOrWorkspaceAccountID: const parameters = { policyID, + domainAccountID: domainOrWorkspaceAccountID, bankName, liabilityType, }; From 01884ec04813646d804a9ed949101d5c9a33171d Mon Sep 17 00:00:00 2001 From: Rayane <77965000+rayane-d@users.noreply.github.com> Date: Mon, 14 Sep 2026 01:41:22 +0100 Subject: [PATCH 2/3] add tests for getDomainOrWorkspaceAccountID --- tests/unit/CardUtilsTest.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/unit/CardUtilsTest.ts b/tests/unit/CardUtilsTest.ts index 3f1a88deb292..e10d00ec9247 100644 --- a/tests/unit/CardUtilsTest.ts +++ b/tests/unit/CardUtilsTest.ts @@ -45,6 +45,7 @@ import { getDisplayableExpensifyCards, getDisplayableThirdPartyCards, getDomainByFundID, + getDomainOrWorkspaceAccountID, getEligibleBankAccountsForCard, getEligibleBankAccountsForUkEuCard, getFeedNameForDisplay, @@ -1410,6 +1411,23 @@ describe('CardUtils', () => { }); }); + describe('getDomainOrWorkspaceAccountID', () => { + it('Should return the domain account that owns a domain feed', () => { + const accountID = getDomainOrWorkspaceAccountID(7654321, {domainID: 1234567}); + expect(accountID).toBe(1234567); + }); + + it('Should return the workspace account when the feed has no domain', () => { + const accountID = getDomainOrWorkspaceAccountID(7654321, {}); + expect(accountID).toBe(7654321); + }); + + it('Should return the workspace account when there is no feed data', () => { + const accountID = getDomainOrWorkspaceAccountID(7654321, undefined); + expect(accountID).toBe(7654321); + }); + }); + describe('getCustomOrFormattedFeedName', () => { beforeAll(() => { IntlStore.load(CONST.LOCALES.EN); From 9cb01baf39e655f290fa12d0d992c07460b12ea2 Mon Sep 17 00:00:00 2001 From: Rayane <77965000+rayane-d@users.noreply.github.com> Date: Mon, 14 Sep 2026 01:43:50 +0100 Subject: [PATCH 3/3] Add a test that card feed liability sends domainAccountID --- tests/actions/CompanyCardsLiabilityTest.ts | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/actions/CompanyCardsLiabilityTest.ts diff --git a/tests/actions/CompanyCardsLiabilityTest.ts b/tests/actions/CompanyCardsLiabilityTest.ts new file mode 100644 index 000000000000..b2657f7c980c --- /dev/null +++ b/tests/actions/CompanyCardsLiabilityTest.ts @@ -0,0 +1,41 @@ +import {setWorkspaceCompanyCardTransactionLiability} from '@libs/actions/CompanyCards'; +import {WRITE_COMMANDS} from '@libs/API/types'; + +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; + +const POLICY_ID = 'A1B2C3D4E5F60718'; +const DOMAIN_ACCOUNT_ID = 1234567; +const FEED = CONST.COMPANY_CARD.FEED_BANK_NAME.VISA; + +describe('actions/CompanyCards setWorkspaceCompanyCardTransactionLiability', () => { + afterEach(() => { + jest.restoreAllMocks(); + }); + + it('targets the feed-owning domain account when restricting deletion on a domain feed', () => { + // Given a domain feed, whose settings live on the +@domain account rather than the workspace account + const apiWriteSpy = jest.spyOn(require('@libs/API'), 'write').mockImplementation(() => Promise.resolve()); + + // When an admin turns off deleting transactions for that feed + setWorkspaceCompanyCardTransactionLiability(DOMAIN_ACCOUNT_ID, POLICY_ID, FEED, CONST.COMPANY_CARDS.DELETE_TRANSACTIONS.RESTRICT); + + // Then the domainAccountID is forwarded to the backend, so the setting is written to the correct account, and the optimistic Onyx write targets that same account. + expect(apiWriteSpy).toHaveBeenCalledWith( + WRITE_COMMANDS.SET_COMPANY_CARD_TRANSACTION_LIABILITY, + expect.objectContaining({ + policyID: POLICY_ID, + bankName: FEED, + liabilityType: CONST.COMPANY_CARDS.DELETE_TRANSACTIONS.RESTRICT, + domainAccountID: DOMAIN_ACCOUNT_ID, + }), + expect.objectContaining({ + optimisticData: expect.arrayContaining([ + expect.objectContaining({ + key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${DOMAIN_ACCOUNT_ID}`, + }), + ]), + }), + ); + }); +});