Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libs/TransactionUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ function getMerchant(transaction: OnyxInputOrEntry<Transaction>, 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)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return DistanceRequestUtils.getDistanceMerchant(true, distanceInMeters, unit, rate, transaction.currency, translateLocal, (digit) =>
toLocaleDigit(IntlStore.getCurrentLocale(), digit),
Expand Down
38 changes: 28 additions & 10 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12766,11 +12766,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;
Expand Down Expand Up @@ -12809,11 +12818,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.
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/TransactionUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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...');
});

Expand Down