Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: RBR applies to newly created distance expenses when it shouldn't #26580

Merged
merged 1 commit into from
Sep 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -298,20 +312,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
Loading