Skip to content

Commit

Permalink
Merge pull request #38823 from Expensify/cmartins-fixDefaultIDs
Browse files Browse the repository at this point in the history
[No QA] Fix off by one error in optimistic distance rate name
  • Loading branch information
marcaaron authored Mar 22, 2024
2 parents 3bea03a + 2b2a523 commit 665a8ad
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libs/PolicyDistanceRatesUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function validateRateValue(values: FormOnyxValues<RateValueForm>, currency: stri
*/
function getOptimisticRateName(rates: Record<string, Rate>): string {
const existingRatesWithSameName = Object.values(rates ?? {}).filter((rate) => (rate.name ?? '').startsWith(CONST.CUSTOM_UNITS.DEFAULT_RATE));
return existingRatesWithSameName.length ? `${CONST.CUSTOM_UNITS.DEFAULT_RATE} ${existingRatesWithSameName.length + 1}` : CONST.CUSTOM_UNITS.DEFAULT_RATE;
return existingRatesWithSameName.length ? `${CONST.CUSTOM_UNITS.DEFAULT_RATE} ${existingRatesWithSameName.length}` : CONST.CUSTOM_UNITS.DEFAULT_RATE;
}

export {validateRateValue, getOptimisticRateName};

0 comments on commit 665a8ad

Please sign in to comment.