Skip to content

Commit

Permalink
Merge pull request #43226 from Expensify/camrtins-fixCustomunitCrash
Browse files Browse the repository at this point in the history
[CP Staging] Fix crash when submitting expense on a newly created workspace

(cherry picked from commit 69863d5)
  • Loading branch information
luacmartins authored and OSBotify committed Jun 6, 2024
1 parent 0459e9f commit e24235d
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 @@ -52,7 +52,7 @@ function getMileageRates(policy: OnyxEntry<Policy>, includeDisabledRates = false
}

Object.entries(distanceUnit.rates).forEach(([rateID, rate]) => {
if (!includeDisabledRates && !rate.enabled) {
if (!includeDisabledRates && rate.enabled === false) {
return;
}

Expand Down Expand Up @@ -89,7 +89,7 @@ function getDefaultMileageRate(policy: OnyxEntry<Policy> | EmptyObject): Mileage
}
const mileageRates = getMileageRates(policy);

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

return {
customUnitRateID: distanceRate.customUnitRateID,
Expand Down
1 change: 1 addition & 0 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2000,6 +2000,7 @@ function buildOptimisticCustomUnits(): OptimisticCustomUnits {
customUnitRateID,
name: CONST.CUSTOM_UNITS.DEFAULT_RATE,
rate: CONST.CUSTOM_UNITS.MILEAGE_IRS_RATE * CONST.POLICY.CUSTOM_UNIT_RATE_BASE_OFFSET,
enabled: true,
currency,
},
},
Expand Down

0 comments on commit e24235d

Please sign in to comment.