Skip to content

Commit fe81f4e

Browse files
Clear stale convertedAmount when moving cross-currency expenses from Self DM
When an unreported expense (from Self DM) is moved to a report with a different currency, the sourceCurrency is undefined. This caused shouldClearConvertedAmount to bail out early, leaving stale convertedAmount/convertedTaxAmount on the transaction. Downstream readers (getBillableAndTaxTotal, calculateGroupTotal) then displayed incorrect Tax and Billable totals while offline. - Fall back to the transaction's own currency when sourceCurrency is missing - Clear convertedTaxAmount alongside convertedAmount in optimistic and failure data Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
1 parent 58141ba commit fe81f4e

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/libs/TransactionUtils/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,11 +1042,17 @@ function getCurrency(transaction: OnyxInputOrEntry<Transaction>): string {
10421042
* Transactions that match the destination currency can keep their convertedAmount since no conversion is needed.
10431043
*/
10441044
function shouldClearConvertedAmount(transaction: OnyxInputOrEntry<Transaction>, sourceCurrency: string | undefined, destinationCurrency: string | undefined): boolean {
1045-
if (!sourceCurrency || !destinationCurrency || sourceCurrency === destinationCurrency) {
1045+
if (!destinationCurrency) {
10461046
return false;
10471047
}
10481048

10491049
const transactionCurrency = getCurrency(transaction);
1050+
const effectiveSourceCurrency = sourceCurrency ?? transactionCurrency;
1051+
1052+
if (effectiveSourceCurrency === destinationCurrency) {
1053+
return false;
1054+
}
1055+
10501056
const transactionMatchesDestination = transactionCurrency === destinationCurrency;
10511057

10521058
return !transactionMatchesDestination;

src/libs/actions/Transaction.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,7 @@ function changeTransactionsReport({
10891089
originalCurrency: shouldCopyOriginalCurrency ? transaction.originalCurrency : null,
10901090
...(shouldClearAmount && {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}),
10911091
...(shouldClearAmount && {convertedAmount: null}),
1092+
...(shouldClearAmount && {convertedTaxAmount: null}),
10921093
...(oldIOUAction ? {linkedTrackedExpenseReportAction: newIOUAction} : {}),
10931094
},
10941095
});
@@ -1112,6 +1113,7 @@ function changeTransactionsReport({
11121113
originalCurrency: transaction.originalCurrency,
11131114
...(shouldClearAmount && {pendingAction: transaction.pendingAction ?? null}),
11141115
...(shouldClearAmount && {convertedAmount: transaction.convertedAmount}),
1116+
...(shouldClearAmount && {convertedTaxAmount: transaction.convertedTaxAmount}),
11151117
},
11161118
});
11171119

0 commit comments

Comments
 (0)