Skip to content

Commit 8c62d02

Browse files
committed
refactor code
1 parent cb0aacf commit 8c62d02

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

src/libs/Violations/ViolationsUtils.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -290,16 +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});
295-
}
296-
297-
if (updatedTransaction?.comment?.customUnit?.customUnitRateID && !getDistanceRateCustomUnitRate(policy, updatedTransaction.comment.customUnit.customUnitRateID)) {
298-
newTransactionViolations.push({
299-
name: CONST.VIOLATIONS.CUSTOM_UNIT_OUT_OF_POLICY,
300-
type: CONST.VIOLATION_TYPES.VIOLATION,
301-
showInReview: true,
302-
});
293+
const customUnitRateID = updatedTransaction?.comment?.customUnit?.customUnitRateID;
294+
if (customUnitRateID) {
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+
}
303305
}
304306

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

0 commit comments

Comments
 (0)