Fix: While scan is in progress, more menu displays submit option#76610
Conversation
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@QichenZhu Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
| return false; | ||
| } | ||
|
|
||
| const isAnyReceiptBeingScanned = reportTransactions?.some((transaction) => isReceiptBeingScanned(transaction)); |
There was a problem hiding this comment.
❌ PERF-2 (docs)
The .some() call with isReceiptBeingScanned(transaction) is an expensive operation (function call) that should be performed AFTER the simple property checks. The transactionAreComplete check on line 150 uses primitive comparisons (transaction.amount !== 0 || transaction.modifiedAmount !== 0) which are much simpler and should execute first to eliminate items early.
Suggested fix: Move the receipt scanning check after the transactionAreComplete check:
const transactionAreComplete = reportTransactions.every((transaction) => transaction.amount !== 0 || transaction.modifiedAmount !== 0);
if (!transactionAreComplete) {
return false;
}
const isAnyReceiptBeingScanned = reportTransactions?.some((transaction) => isReceiptBeingScanned(transaction));
if (isAnyReceiptBeingScanned) {
return false;
}|
For the scan fails issue, we hide the submit button when transactions have |
JmillsExpensify
left a comment
There was a problem hiding this comment.
Yeah, you shouldn't be able to submit a scanning expense. Product approved.
| const hasSmartScanFailedViolation = transactions?.some((transaction) => { | ||
| const transactionViolations = getTransactionViolations(transaction, violations, currentUserEmail, currentUserAccountID, report, policy); | ||
| return transactionViolations?.some((violation) => violation.name === CONST.VIOLATIONS.SMARTSCAN_FAILED); | ||
| }); |
There was a problem hiding this comment.
Is this approach better than checking transaction?.receipt?.state === CONST.IOU.RECEIPT_STATE.SCAN_FAILED?
Also, please extract it into a util since this logic is duplicated in three places.
There was a problem hiding this comment.
I tested both approaches and found that transaction?.receipt?.state remains SCANFAILED even after the user manually enters the missing fields (amount, merchant, etc.). This means if we check the receipt state directly, the submit button would stay hidden once a scan fails, even after the user fixes everything:
MacOS-Chrome.mp4
Meanwhile the violation approach allows submit action once the user has addressed the failed scan violation. In this case, entering either amount and merchant field should be enough, as the backend accept this condition as well
MacOS-Chrome.mp4
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid-native.webmAndroid: mWeb Chromeandroid-web.webmiOS: HybridAppios-native.moviOS: mWeb Safariios-web.movMacOS: Chrome / SafariScreen.Recording.2025-12-12.at.12.19.47.AM.mov |
|
NAB: We are adding optional arguments to isSubmitAction(), but I can't test whether we need to update its usage in useTools() which is not used in our app yet. cc @carlosmiceli |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/madmax330 in version: 9.2.79-0 🚀
|
|
🚀 Deployed to staging by https://github.com/madmax330 in version: 9.2.81-0 🚀
|
|
🚀 Deployed to production by https://github.com/AndrewGable in version: 9.2.81-5 🚀
|
|
🚀 Deployed to production by https://github.com/AndrewGable in version: 9.2.81-5 🚀
|
Explanation of Change
This PR prevents the submit option from being shown in report secondary actions when any receipt is being scanned
Fixed Issues
$ #75840
PROPOSAL: #75840 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android-Native.mp4
Android: mWeb Chrome
Android-mWeb.mp4
iOS: Native
iOS-Native.mp4
iOS: mWeb Safari
iOS-mWeb.mp4
MacOS: Chrome / Safari
MacOS-Chrome.mp4