Skip to content

Commit

Permalink
Merge pull request Expensify#45146 from paultsimura/fix/44154-rate-re…
Browse files Browse the repository at this point in the history
…moved

fix: Optimistically disable the distance rate on removal
  • Loading branch information
arosiclair authored Jul 17, 2024
2 parents a129673 + 9cf348c commit a26d766
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libs/DistanceRequestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ function getDefaultMileageRate(policy: OnyxInputOrEntry<Policy>): MileageRate |
if (!distanceUnit?.rates) {
return;
}
const mileageRates = getMileageRates(policy);
const mileageRates = Object.values(getMileageRates(policy));

const distanceRate = Object.values(mileageRates).find((rate) => rate.name === CONST.CUSTOM_UNITS.DEFAULT_RATE) ?? Object.values(mileageRates)[0] ?? {};
const distanceRate = mileageRates.find((rate) => rate.name === CONST.CUSTOM_UNITS.DEFAULT_RATE) ?? mileageRates[0] ?? {};

return {
customUnitRateID: distanceRate.customUnitRateID,
Expand Down
1 change: 1 addition & 0 deletions src/libs/actions/Policy/DistanceRate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ function deletePolicyDistanceRates(policyID: string, customUnit: CustomUnit, rat
if (rateIDsToDelete.includes(rateID)) {
optimisticRates[rateID] = {
...currentRates[rateID],
enabled: false,
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
};
failureRates[rateID] = {
Expand Down

0 comments on commit a26d766

Please sign in to comment.