From dca0d017d576e9f93d976c161383ed3c6f50e7c6 Mon Sep 17 00:00:00 2001 From: apeyada Date: Thu, 16 Oct 2025 18:17:48 +0100 Subject: [PATCH 1/3] fix LHN shows "Pending..." as distance rate after rejecting the distance expense --- src/libs/actions/IOU.ts | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index b699f9120449..1a6dea9857a4 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -12650,11 +12650,20 @@ function rejectMoneyRequest(transactionID: string, reportID: string, comment: st } } else { // For reports with single expense: Delete the report - optimisticData.push({ - onyxMethod: Onyx.METHOD.SET, - key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, - value: null, - }); + optimisticData.push( + { + onyxMethod: Onyx.METHOD.SET, + key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + value: null, + }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, + value: { + reportID: CONST.REPORT.UNREPORTED_REPORT_ID, + }, + }, + ); // And delete the corresponding REPORTPREVIEW action const parentReportID = report?.parentReportID; @@ -12693,11 +12702,20 @@ function rejectMoneyRequest(transactionID: string, reportID: string, comment: st }); // Add failure data to restore the report - failureData.push({ - onyxMethod: Onyx.METHOD.SET, - key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, - value: report, - }); + failureData.push( + { + onyxMethod: Onyx.METHOD.SET, + key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + value: report, + }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, + value: { + reportID, + }, + }, + ); if (isUserOnSearchPage) { // Navigate to the existing Reports > Expense view. From 44d5c86f89ba4bc730d72fdbe830167394cae77e Mon Sep 17 00:00:00 2001 From: apeyada Date: Fri, 17 Oct 2025 09:33:44 +0100 Subject: [PATCH 2/3] fix offline issue --- src/libs/TransactionUtils/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/TransactionUtils/index.ts b/src/libs/TransactionUtils/index.ts index 15fa71b15142..4fbbbc19a698 100644 --- a/src/libs/TransactionUtils/index.ts +++ b/src/libs/TransactionUtils/index.ts @@ -823,7 +823,7 @@ function getMerchant(transaction: OnyxInputOrEntry, policyParam: On const mileageRate = DistanceRequestUtils.getRate({transaction, policy}); const {unit, rate} = mileageRate; const distanceInMeters = getDistanceInMeters(transaction, unit); - if (!isUnreportedAndHasInvalidDistanceRateTransaction(transaction, policy)) { + if (policy && !isUnreportedAndHasInvalidDistanceRateTransaction(transaction, policy)) { return DistanceRequestUtils.getDistanceMerchant(true, distanceInMeters, unit, rate, transaction.currency, translateLocal, (digit) => toLocaleDigit(IntlStore.getCurrentLocale(), digit), ); From 78d1e7d97b2ecb804f082a9323f03253a83badb5 Mon Sep 17 00:00:00 2001 From: apeyada Date: Fri, 17 Oct 2025 10:22:18 +0100 Subject: [PATCH 3/3] fix unit test --- tests/unit/TransactionUtilsTest.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/unit/TransactionUtilsTest.ts b/tests/unit/TransactionUtilsTest.ts index d482d7043c52..8ec4a69ad908 100644 --- a/tests/unit/TransactionUtilsTest.ts +++ b/tests/unit/TransactionUtilsTest.ts @@ -537,7 +537,8 @@ describe('TransactionUtils', () => { const transaction = generateTransaction({ iouRequestType: CONST.IOU.REQUEST_TYPE.DISTANCE, }); - const merchant = TransactionUtils.getMerchant(transaction); + const policy = {role: CONST.POLICY.ROLE.ADMIN} as Policy; + const merchant = TransactionUtils.getMerchant(transaction, policy); expect(merchant).toBe('Pending...'); });