Skip to content

Commit

Permalink
Merge pull request #26580 from Pujan92/fix/26567
Browse files Browse the repository at this point in the history
Fix: RBR applies to newly created distance expenses when it shouldn't
  • Loading branch information
Hayata Suenaga authored Sep 2, 2023
2 parents 7e3e760 + 5c25683 commit e088539
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/libs/TransactionUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,20 @@ function getCreated(transaction) {
return '';
}

/*
* @param {Object} transaction
* @param {Object} transaction.comment
* @param {String} transaction.comment.type
* @param {Object} [transaction.comment.customUnit]
* @param {String} [transaction.comment.customUnit.name]
* @returns {Boolean}
*/
function isDistanceRequest(transaction) {
const type = lodashGet(transaction, 'comment.type');
const customUnitName = lodashGet(transaction, 'comment.customUnit.name');
return type === CONST.TRANSACTION.TYPE.CUSTOM_UNIT && customUnitName === CONST.CUSTOM_UNITS.NAME_DISTANCE;
}

function isReceiptBeingScanned(transaction) {
return _.contains([CONST.IOU.RECEIPT_STATE.SCANREADY, CONST.IOU.RECEIPT_STATE.SCANNING], transaction.receipt.state);
}
Expand All @@ -248,7 +262,7 @@ function isReceiptBeingScanned(transaction) {
* @returns {Boolean}
*/
function hasMissingSmartscanFields(transaction) {
return hasReceipt(transaction) && !isReceiptBeingScanned(transaction) && !areModifiedFieldsPopulated(transaction);
return hasReceipt(transaction) && !isDistanceRequest(transaction) && !isReceiptBeingScanned(transaction) && !areModifiedFieldsPopulated(transaction);
}

/**
Expand Down Expand Up @@ -301,20 +315,6 @@ function validateWaypoints(waypoints) {
return true;
}

/*
* @param {Object} transaction
* @param {Object} transaction.comment
* @param {String} transaction.comment.type
* @param {Object} [transaction.comment.customUnit]
* @param {String} [transaction.comment.customUnit.name]
* @returns {Boolean}
*/
function isDistanceRequest(transaction) {
const type = lodashGet(transaction, 'comment.type');
const customUnitName = lodashGet(transaction, 'comment.customUnit.name');
return type === CONST.TRANSACTION.TYPE.CUSTOM_UNIT && customUnitName === CONST.CUSTOM_UNITS.NAME_DISTANCE;
}

export {
buildOptimisticTransaction,
getUpdatedTransaction,
Expand Down

0 comments on commit e088539

Please sign in to comment.