Skip to content
Merged
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
12 changes: 7 additions & 5 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3170,13 +3170,13 @@ function updateMoneyRequestDistanceRate(
policy: OnyxEntry<OnyxTypes.Policy>,
policyTagList: OnyxEntry<OnyxTypes.PolicyTagLists>,
policyCategories: OnyxEntry<OnyxTypes.PolicyCategories>,
taxAmount?: number,
taxCode?: string,
updatedTaxAmount?: number,
updatedTaxCode?: string,
) {
const transactionChanges: TransactionChanges = {
customUnitRateID: rateID,
...(taxAmount ? {taxAmount} : {}),
...(taxCode ? {taxCode} : {}),
...(typeof updatedTaxAmount === 'number' ? {taxAmount: updatedTaxAmount} : {}),
...(updatedTaxCode ? {taxCode: updatedTaxCode} : {}),
};
const allReports = ReportConnection.getAllReports();
const transactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`] ?? null;
Expand All @@ -3188,7 +3188,9 @@ function updateMoneyRequestDistanceRate(
data = getUpdateMoneyRequestParams(transactionID, transactionThreadReportID, transactionChanges, policy, policyTagList, policyCategories, true);
}
const {params, onyxData} = data;
API.write(WRITE_COMMANDS.UPDATE_MONEY_REQUEST_DISTANCE_RATE, params, onyxData);
// `taxAmount` & `taxCode` only needs to be updated in the optimistic data, so we need to remove them from the params
const {taxAmount, taxCode, ...paramsWithoutTaxUpdated} = params;
API.write(WRITE_COMMANDS.UPDATE_MONEY_REQUEST_DISTANCE_RATE, paramsWithoutTaxUpdated, onyxData);
}

/** Edits an existing distance expense */
Expand Down