Skip to content

Commit

Permalink
Merge pull request #49475 from Krishna2323/krishna2323/issue/49459
Browse files Browse the repository at this point in the history
fix: Distance rates - Change Rate to default leads to app crash.
  • Loading branch information
carlosmiceli committed Sep 19, 2024
2 parents 8d18ce3 + ce02d0e commit 49d1b0d
Showing 1 changed file with 7 additions and 5 deletions.
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

0 comments on commit 49d1b0d

Please sign in to comment.