Skip to content

Commit

Permalink
Merge pull request #26643 from Expensify/alberto-checkfields
Browse files Browse the repository at this point in the history
Update empty field check logic
  • Loading branch information
MariaHCD authored Sep 4, 2023
2 parents a7cba2d + 60576f0 commit 7eb96d8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/libs/TransactionUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,14 @@ function hasReceipt(transaction) {
* @param {Object} transaction
* @returns {Boolean}
*/
function areModifiedFieldsPopulated(transaction) {
return transaction.modifiedMerchant !== CONST.TRANSACTION.UNKNOWN_MERCHANT && transaction.modifiedAmount !== 0 && transaction.modifiedCreated !== '';
function areRequiredFieldsEmpty(transaction) {
return (
transaction.modifiedMerchant === CONST.TRANSACTION.UNKNOWN_MERCHANT ||
(transaction.modifiedMerchant === '' &&
(transaction.merchant === CONST.TRANSACTION.UNKNOWN_MERCHANT || transaction.merchant === '' || transaction.merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT)) ||
(transaction.modifiedAmount === 0 && transaction.amount === 0) ||
(transaction.modifiedCreated === '' && transaction.created === '')
);
}

/**
Expand Down Expand Up @@ -262,7 +268,7 @@ function isReceiptBeingScanned(transaction) {
* @returns {Boolean}
*/
function hasMissingSmartscanFields(transaction) {
return hasReceipt(transaction) && !isDistanceRequest(transaction) && !isReceiptBeingScanned(transaction) && !areModifiedFieldsPopulated(transaction);
return hasReceipt(transaction) && !isDistanceRequest(transaction) && !isReceiptBeingScanned(transaction) && areRequiredFieldsEmpty(transaction);
}

/**
Expand Down

0 comments on commit 7eb96d8

Please sign in to comment.