From 2a82ab9463fea01f507d1ec46918656c4bff4504 Mon Sep 17 00:00:00 2001 From: MelvinBot Date: Thu, 26 Feb 2026 20:23:54 +0000 Subject: [PATCH 1/6] Fix split distance expense using wrong currency after workspace currency change When splitting a distance expense, the currency for the merchant string was sourced from the current policy's mileage rate instead of the original transaction's currency. If the workspace currency changed after the expense was created, the split would display the new currency instead of the original. Swap the fallback priority in updateSplitExpenseDistanceFromAmount and updateSplitExpenseField so the original transaction currency takes precedence over the mileage rate currency. Co-authored-by: Puneet Lath --- src/libs/actions/IOU/Split.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/IOU/Split.ts b/src/libs/actions/IOU/Split.ts index e08e8c74c8e3b..070b11260593d 100644 --- a/src/libs/actions/IOU/Split.ts +++ b/src/libs/actions/IOU/Split.ts @@ -1911,7 +1911,7 @@ function updateSplitExpenseDistanceFromAmount( quantity, }; - const merchant = getDistanceMerchantFromDistance(distanceInUnits, unit, rate, mileageRate?.currency ?? transactionCurrency ?? CONST.CURRENCY.USD, transactionCurrency); + const merchant = getDistanceMerchantFromDistance(distanceInUnits, unit, rate, transactionCurrency ?? mileageRate?.currency ?? CONST.CURRENCY.USD, transactionCurrency); return {customUnit, merchant}; } @@ -2339,7 +2339,7 @@ function updateSplitExpenseField( updatedItem.amount = calculatedAmount; // Update merchant for distance transactions - const currency = mileageRate?.currency ?? originalTransaction.currency ?? CONST.CURRENCY.USD; + const currency = originalTransaction.currency ?? mileageRate?.currency ?? CONST.CURRENCY.USD; updatedItem.merchant = getDistanceMerchantFromDistance(distanceInUnits, unit, rate, currency, originalTransaction.currency); } } From fa34aa80057f7821b600afd4419de6d8f3677168 Mon Sep 17 00:00:00 2001 From: MelvinBot Date: Thu, 26 Feb 2026 20:33:48 +0000 Subject: [PATCH 2/6] Remove unused transactionCurrency param from getDistanceMerchantFromDistance Co-authored-by: Yauheni Horbach --- src/libs/actions/IOU/Split.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/actions/IOU/Split.ts b/src/libs/actions/IOU/Split.ts index 070b11260593d..88235409f6bc1 100644 --- a/src/libs/actions/IOU/Split.ts +++ b/src/libs/actions/IOU/Split.ts @@ -1864,13 +1864,13 @@ function setIndividualShare(transactionID: string, participantAccountID: number, /** * Calculate merchant for distance transactions based on distance and rate */ -function getDistanceMerchantFromDistance(distanceInUnits: number, unit: Unit | undefined, rate: number | undefined, currency: string, transactionCurrency?: string): string { +function getDistanceMerchantFromDistance(distanceInUnits: number, unit: Unit | undefined, rate: number | undefined, currency: string): string { if (!rate || rate <= 0 || !unit) { return ''; } const distanceInMeters = DistanceRequestUtils.convertToDistanceInMeters(distanceInUnits, unit); - const currencyForMerchant = currency ?? transactionCurrency ?? CONST.CURRENCY.USD; + const currencyForMerchant = currency; const currentLocale = IntlStore.getCurrentLocale(); return DistanceRequestUtils.getDistanceMerchant( true, @@ -1911,7 +1911,7 @@ function updateSplitExpenseDistanceFromAmount( quantity, }; - const merchant = getDistanceMerchantFromDistance(distanceInUnits, unit, rate, transactionCurrency ?? mileageRate?.currency ?? CONST.CURRENCY.USD, transactionCurrency); + const merchant = getDistanceMerchantFromDistance(distanceInUnits, unit, rate, transactionCurrency ?? mileageRate?.currency ?? CONST.CURRENCY.USD); return {customUnit, merchant}; } @@ -2340,7 +2340,7 @@ function updateSplitExpenseField( // Update merchant for distance transactions const currency = originalTransaction.currency ?? mileageRate?.currency ?? CONST.CURRENCY.USD; - updatedItem.merchant = getDistanceMerchantFromDistance(distanceInUnits, unit, rate, currency, originalTransaction.currency); + updatedItem.merchant = getDistanceMerchantFromDistance(distanceInUnits, unit, rate, currency); } } } From e0542197248ff1fbec953f292b90ebeef142588e Mon Sep 17 00:00:00 2001 From: MelvinBot Date: Thu, 26 Feb 2026 21:11:29 +0000 Subject: [PATCH 3/6] Fix: Restore areAllConnectionsSet to DerivedValueContext type The areAllConnectionsSet property was lost during the merge of PR #83456 to main. The test file expects this property on DerivedValueContext but the type definition and index.ts were missing it, causing typecheck to fail. Co-authored-by: Puneet Lath --- src/libs/actions/OnyxDerived/index.ts | 2 ++ src/libs/actions/OnyxDerived/types.ts | 1 + tests/unit/CardFeedErrorsDerivedValueTest.ts | 1 + tests/unit/OnyxDerivedTest.tsx | 3 ++- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/OnyxDerived/index.ts b/src/libs/actions/OnyxDerived/index.ts index 81777d0e6e0af..eab71376dda59 100644 --- a/src/libs/actions/OnyxDerived/index.ts +++ b/src/libs/actions/OnyxDerived/index.ts @@ -56,6 +56,7 @@ function init() { const context: DerivedValueContext = { currentValue: undefined, sourceValues: undefined, + areAllConnectionsSet: false, }; const recomputeDerivedValue = (sourceKey?: string, sourceValue?: unknown, triggeredByIndex?: number) => { @@ -74,6 +75,7 @@ function init() { } context.currentValue = derivedValue; + context.areAllConnectionsSet = areAllConnectionsSet; context.sourceValues = sourceKey && sourceValue !== undefined ? {[sourceKey]: sourceValue} : undefined; // @ts-expect-error TypeScript can't confirm the shape of dependencyValues matches the compute function's parameters diff --git a/src/libs/actions/OnyxDerived/types.ts b/src/libs/actions/OnyxDerived/types.ts index a7b14999a9bad..8933579ea8874 100644 --- a/src/libs/actions/OnyxDerived/types.ts +++ b/src/libs/actions/OnyxDerived/types.ts @@ -16,6 +16,7 @@ type DerivedSourceValues = Partial<{ type DerivedValueContext>> = { currentValue?: OnyxValue; sourceValues?: DerivedSourceValues; + areAllConnectionsSet: boolean; }; /** diff --git a/tests/unit/CardFeedErrorsDerivedValueTest.ts b/tests/unit/CardFeedErrorsDerivedValueTest.ts index c684cd529a809..7f292d8dbb331 100644 --- a/tests/unit/CardFeedErrorsDerivedValueTest.ts +++ b/tests/unit/CardFeedErrorsDerivedValueTest.ts @@ -10,6 +10,7 @@ import type {CardFeedWithDomainID, CardFeedWithNumber} from '@src/types/onyx/Car const DERIVED_VALUE_CONTEXT: DerivedValueContext = { currentValue: undefined, sourceValues: undefined, + areAllConnectionsSet: false, }; const CARD_FEEDS = { diff --git a/tests/unit/OnyxDerivedTest.tsx b/tests/unit/OnyxDerivedTest.tsx index d753e2095788a..3ba278ab6eae5 100644 --- a/tests/unit/OnyxDerivedTest.tsx +++ b/tests/unit/OnyxDerivedTest.tsx @@ -123,8 +123,9 @@ describe('OnyxDerived', () => { const transaction = createRandomTransaction(1); // When the report attributes are recomputed with both report and transaction updates - reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], {}); + reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], {areAllConnectionsSet: false}); const reportAttributesComputedValue = reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], { + areAllConnectionsSet: false, sourceValues: { [ONYXKEYS.COLLECTION.REPORT]: { [`${ONYXKEYS.COLLECTION.REPORT}${reportID1}`]: reports[`${ONYXKEYS.COLLECTION.REPORT}${reportID1}`], From dd82e84107fa9e857c214da796f82db4f6d54857 Mon Sep 17 00:00:00 2001 From: MelvinBot Date: Thu, 26 Feb 2026 21:20:55 +0000 Subject: [PATCH 4/6] Revert unrelated TS changes (OnyxDerived areAllConnectionsSet) Co-authored-by: Yauheni Horbach --- src/libs/actions/OnyxDerived/index.ts | 2 -- src/libs/actions/OnyxDerived/types.ts | 1 - tests/unit/CardFeedErrorsDerivedValueTest.ts | 1 - tests/unit/OnyxDerivedTest.tsx | 3 +-- 4 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/libs/actions/OnyxDerived/index.ts b/src/libs/actions/OnyxDerived/index.ts index eab71376dda59..81777d0e6e0af 100644 --- a/src/libs/actions/OnyxDerived/index.ts +++ b/src/libs/actions/OnyxDerived/index.ts @@ -56,7 +56,6 @@ function init() { const context: DerivedValueContext = { currentValue: undefined, sourceValues: undefined, - areAllConnectionsSet: false, }; const recomputeDerivedValue = (sourceKey?: string, sourceValue?: unknown, triggeredByIndex?: number) => { @@ -75,7 +74,6 @@ function init() { } context.currentValue = derivedValue; - context.areAllConnectionsSet = areAllConnectionsSet; context.sourceValues = sourceKey && sourceValue !== undefined ? {[sourceKey]: sourceValue} : undefined; // @ts-expect-error TypeScript can't confirm the shape of dependencyValues matches the compute function's parameters diff --git a/src/libs/actions/OnyxDerived/types.ts b/src/libs/actions/OnyxDerived/types.ts index 8933579ea8874..a7b14999a9bad 100644 --- a/src/libs/actions/OnyxDerived/types.ts +++ b/src/libs/actions/OnyxDerived/types.ts @@ -16,7 +16,6 @@ type DerivedSourceValues = Partial<{ type DerivedValueContext>> = { currentValue?: OnyxValue; sourceValues?: DerivedSourceValues; - areAllConnectionsSet: boolean; }; /** diff --git a/tests/unit/CardFeedErrorsDerivedValueTest.ts b/tests/unit/CardFeedErrorsDerivedValueTest.ts index 7f292d8dbb331..c684cd529a809 100644 --- a/tests/unit/CardFeedErrorsDerivedValueTest.ts +++ b/tests/unit/CardFeedErrorsDerivedValueTest.ts @@ -10,7 +10,6 @@ import type {CardFeedWithDomainID, CardFeedWithNumber} from '@src/types/onyx/Car const DERIVED_VALUE_CONTEXT: DerivedValueContext = { currentValue: undefined, sourceValues: undefined, - areAllConnectionsSet: false, }; const CARD_FEEDS = { diff --git a/tests/unit/OnyxDerivedTest.tsx b/tests/unit/OnyxDerivedTest.tsx index 3ba278ab6eae5..d753e2095788a 100644 --- a/tests/unit/OnyxDerivedTest.tsx +++ b/tests/unit/OnyxDerivedTest.tsx @@ -123,9 +123,8 @@ describe('OnyxDerived', () => { const transaction = createRandomTransaction(1); // When the report attributes are recomputed with both report and transaction updates - reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], {areAllConnectionsSet: false}); + reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], {}); const reportAttributesComputedValue = reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], { - areAllConnectionsSet: false, sourceValues: { [ONYXKEYS.COLLECTION.REPORT]: { [`${ONYXKEYS.COLLECTION.REPORT}${reportID1}`]: reports[`${ONYXKEYS.COLLECTION.REPORT}${reportID1}`], From 01d9cd33ad0d6d7f71b9ca746e34199b47198e43 Mon Sep 17 00:00:00 2001 From: MelvinBot Date: Thu, 26 Feb 2026 21:27:33 +0000 Subject: [PATCH 5/6] Restore areAllConnectionsSet to DerivedValueContext type The previous revert (dd82e84) removed areAllConnectionsSet from DerivedValueContext, but CompanyCardsRBRTest.ts on main (added by PR #83456) requires this property, causing a typecheck failure. Co-authored-by: Puneet Lath --- src/libs/actions/OnyxDerived/index.ts | 2 ++ src/libs/actions/OnyxDerived/types.ts | 1 + tests/unit/CardFeedErrorsDerivedValueTest.ts | 1 + tests/unit/OnyxDerivedTest.tsx | 3 ++- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/OnyxDerived/index.ts b/src/libs/actions/OnyxDerived/index.ts index 81777d0e6e0af..eab71376dda59 100644 --- a/src/libs/actions/OnyxDerived/index.ts +++ b/src/libs/actions/OnyxDerived/index.ts @@ -56,6 +56,7 @@ function init() { const context: DerivedValueContext = { currentValue: undefined, sourceValues: undefined, + areAllConnectionsSet: false, }; const recomputeDerivedValue = (sourceKey?: string, sourceValue?: unknown, triggeredByIndex?: number) => { @@ -74,6 +75,7 @@ function init() { } context.currentValue = derivedValue; + context.areAllConnectionsSet = areAllConnectionsSet; context.sourceValues = sourceKey && sourceValue !== undefined ? {[sourceKey]: sourceValue} : undefined; // @ts-expect-error TypeScript can't confirm the shape of dependencyValues matches the compute function's parameters diff --git a/src/libs/actions/OnyxDerived/types.ts b/src/libs/actions/OnyxDerived/types.ts index a7b14999a9bad..8933579ea8874 100644 --- a/src/libs/actions/OnyxDerived/types.ts +++ b/src/libs/actions/OnyxDerived/types.ts @@ -16,6 +16,7 @@ type DerivedSourceValues = Partial<{ type DerivedValueContext>> = { currentValue?: OnyxValue; sourceValues?: DerivedSourceValues; + areAllConnectionsSet: boolean; }; /** diff --git a/tests/unit/CardFeedErrorsDerivedValueTest.ts b/tests/unit/CardFeedErrorsDerivedValueTest.ts index c684cd529a809..7f292d8dbb331 100644 --- a/tests/unit/CardFeedErrorsDerivedValueTest.ts +++ b/tests/unit/CardFeedErrorsDerivedValueTest.ts @@ -10,6 +10,7 @@ import type {CardFeedWithDomainID, CardFeedWithNumber} from '@src/types/onyx/Car const DERIVED_VALUE_CONTEXT: DerivedValueContext = { currentValue: undefined, sourceValues: undefined, + areAllConnectionsSet: false, }; const CARD_FEEDS = { diff --git a/tests/unit/OnyxDerivedTest.tsx b/tests/unit/OnyxDerivedTest.tsx index d753e2095788a..3ba278ab6eae5 100644 --- a/tests/unit/OnyxDerivedTest.tsx +++ b/tests/unit/OnyxDerivedTest.tsx @@ -123,8 +123,9 @@ describe('OnyxDerived', () => { const transaction = createRandomTransaction(1); // When the report attributes are recomputed with both report and transaction updates - reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], {}); + reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], {areAllConnectionsSet: false}); const reportAttributesComputedValue = reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], { + areAllConnectionsSet: false, sourceValues: { [ONYXKEYS.COLLECTION.REPORT]: { [`${ONYXKEYS.COLLECTION.REPORT}${reportID1}`]: reports[`${ONYXKEYS.COLLECTION.REPORT}${reportID1}`], From d169565f9460f082cbc7aaa09dd210118c03a000 Mon Sep 17 00:00:00 2001 From: MelvinBot Date: Fri, 27 Feb 2026 08:23:28 +0000 Subject: [PATCH 6/6] Remove non-split-related changes (OnyxDerived, tests) Reverts changes to OnyxDerived/index.ts, OnyxDerived/types.ts, CardFeedErrorsDerivedValueTest.ts, and OnyxDerivedTest.tsx to keep only the split distance currency fix. Co-authored-by: Yauheni Horbach --- src/libs/actions/OnyxDerived/index.ts | 2 -- src/libs/actions/OnyxDerived/types.ts | 1 - tests/unit/CardFeedErrorsDerivedValueTest.ts | 1 - tests/unit/OnyxDerivedTest.tsx | 3 +-- 4 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/libs/actions/OnyxDerived/index.ts b/src/libs/actions/OnyxDerived/index.ts index eab71376dda59..81777d0e6e0af 100644 --- a/src/libs/actions/OnyxDerived/index.ts +++ b/src/libs/actions/OnyxDerived/index.ts @@ -56,7 +56,6 @@ function init() { const context: DerivedValueContext = { currentValue: undefined, sourceValues: undefined, - areAllConnectionsSet: false, }; const recomputeDerivedValue = (sourceKey?: string, sourceValue?: unknown, triggeredByIndex?: number) => { @@ -75,7 +74,6 @@ function init() { } context.currentValue = derivedValue; - context.areAllConnectionsSet = areAllConnectionsSet; context.sourceValues = sourceKey && sourceValue !== undefined ? {[sourceKey]: sourceValue} : undefined; // @ts-expect-error TypeScript can't confirm the shape of dependencyValues matches the compute function's parameters diff --git a/src/libs/actions/OnyxDerived/types.ts b/src/libs/actions/OnyxDerived/types.ts index 8933579ea8874..a7b14999a9bad 100644 --- a/src/libs/actions/OnyxDerived/types.ts +++ b/src/libs/actions/OnyxDerived/types.ts @@ -16,7 +16,6 @@ type DerivedSourceValues = Partial<{ type DerivedValueContext>> = { currentValue?: OnyxValue; sourceValues?: DerivedSourceValues; - areAllConnectionsSet: boolean; }; /** diff --git a/tests/unit/CardFeedErrorsDerivedValueTest.ts b/tests/unit/CardFeedErrorsDerivedValueTest.ts index 7f292d8dbb331..c684cd529a809 100644 --- a/tests/unit/CardFeedErrorsDerivedValueTest.ts +++ b/tests/unit/CardFeedErrorsDerivedValueTest.ts @@ -10,7 +10,6 @@ import type {CardFeedWithDomainID, CardFeedWithNumber} from '@src/types/onyx/Car const DERIVED_VALUE_CONTEXT: DerivedValueContext = { currentValue: undefined, sourceValues: undefined, - areAllConnectionsSet: false, }; const CARD_FEEDS = { diff --git a/tests/unit/OnyxDerivedTest.tsx b/tests/unit/OnyxDerivedTest.tsx index 3ba278ab6eae5..d753e2095788a 100644 --- a/tests/unit/OnyxDerivedTest.tsx +++ b/tests/unit/OnyxDerivedTest.tsx @@ -123,9 +123,8 @@ describe('OnyxDerived', () => { const transaction = createRandomTransaction(1); // When the report attributes are recomputed with both report and transaction updates - reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], {areAllConnectionsSet: false}); + reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], {}); const reportAttributesComputedValue = reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], { - areAllConnectionsSet: false, sourceValues: { [ONYXKEYS.COLLECTION.REPORT]: { [`${ONYXKEYS.COLLECTION.REPORT}${reportID1}`]: reports[`${ONYXKEYS.COLLECTION.REPORT}${reportID1}`],