Skip to content

Commit e081568

Browse files
authored
Merge pull request Expensify#68091 from thelullabyy/fix/67371-invalid-rate-error-not-seen
Expense - Invalid rate error not automatically seen when moving distance expense to new report
2 parents 62c843f + cd1da2b commit e081568

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/libs/Violations/ViolationsUtils.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,18 @@ const ViolationsUtils = {
290290
: getTagViolationsForMultiLevelTags(updatedTransaction, newTransactionViolations, policyTagList, hasDependentTags);
291291
}
292292

293-
if (updatedTransaction?.comment?.customUnit?.customUnitRateID && !!getDistanceRateCustomUnitRate(policy, updatedTransaction?.comment?.customUnit?.customUnitRateID)) {
294-
newTransactionViolations = reject(newTransactionViolations, {name: CONST.VIOLATIONS.CUSTOM_UNIT_OUT_OF_POLICY});
293+
const customUnitRateID = updatedTransaction?.comment?.customUnit?.customUnitRateID;
294+
if (customUnitRateID && customUnitRateID.length > 0) {
295+
const distanceRateCustomRate = getDistanceRateCustomUnitRate(policy, customUnitRateID);
296+
if (distanceRateCustomRate) {
297+
newTransactionViolations = reject(newTransactionViolations, {name: CONST.VIOLATIONS.CUSTOM_UNIT_OUT_OF_POLICY});
298+
} else {
299+
newTransactionViolations.push({
300+
name: CONST.VIOLATIONS.CUSTOM_UNIT_OUT_OF_POLICY,
301+
type: CONST.VIOLATION_TYPES.VIOLATION,
302+
showInReview: true,
303+
});
304+
}
295305
}
296306

297307
const isControlPolicy = policy.type === CONST.POLICY.TYPE.CORPORATE;

0 commit comments

Comments
 (0)