Repository navigation
Fix: Web-Scan-Scan expense from Reports, the existing report disappears in filter for a while - #82042
Conversation
|
@ZhenjaHorbach 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] |
| const reportNameValuePair = allReportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report.chatReportID}`]; | ||
| const reportActions = Object.values(allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`] ?? []); | ||
| const reportTransactions = transactionsByReportID[report.reportID] ?? []; | ||
| const reportMetadata = allReportMetadata?.[`${ONYXKEYS.COLLECTION.REPORT_METADATA}${report.reportID}`]; |
There was a problem hiding this comment.
❌ CONSISTENCY-2 (docs)
The inline check isOpenExpenseReport(report) && isCurrentUserSubmitter(report) && reportTransactions.length > 0 && \!isArchivedReport(reportNameValuePair) is missing critical business logic that was present in the original isSubmitAction function.
Missing checks from original isSubmitAction:
hasPendingDEWSubmit(reportMetadata, hasDynamicExternalWorkflow(policy))- prevents submission when pending Dynamic External WorkflowtransactionAreCompletecheck - ensures all transactions have valid amounts (transaction.amount \!== 0 || transaction.modifiedAmount \!== 0)- All-pending check - returns false if
reportTransactions.every((transaction) => isPending(transaction)) - Scanning check - returns false if
reportTransactions.some((transaction) => isScanning(transaction)) - Violation checks - checks for submission-blocking violations when violations are provided
- Self-approval prevention - prevents showing submit when
submitToAccountID === report.ownerAccountID && policy?.preventSelfApproval
Suggested fix:
Instead of replacing isSubmitAction with an incomplete inline check, either:
- Continue using
isSubmitActionbut adjust its logic if needed, OR - If the inline check is intentional for this specific use case, add a comment explaining why the simpler logic is correct here
If option 2 is chosen, the comment should explain why checks like scanning receipts, pending transactions, DEW submit status, and violations don't need to be checked in the todos context.
Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
| continue; | ||
| } | ||
| const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`]; | ||
| const reportNameValuePair = allReportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report.chatReportID}`]; |
There was a problem hiding this comment.
❌ PERF-2 (docs)
The reportActions computation using Object.values() happens unconditionally for every report, but it is only used in the isExportAction check. If the earlier checks (shouldShowInSubmitTodo, isApproveAction, or isPrimaryPayAction) would result in early returns or if isExportAction is not called, this computation is wasted.
Suggested fix:
Move the reportActions computation to just before it's needed:
const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`];
const reportNameValuePair = allReportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report.chatReportID}`];
const reportTransactions = transactionsByReportID[report.reportID] ?? [];
const reportMetadata = allReportMetadata?.[`${ONYXKEYS.COLLECTION.REPORT_METADATA}${report.reportID}`];
const shouldShowInSubmitTodo = isOpenExpenseReport(report) && isCurrentUserSubmitter(report) && reportTransactions.length > 0 && !isArchivedReport(reportNameValuePair);
if (shouldShowInSubmitTodo) {
reportsToSubmit.push(report);
}
if (isApproveAction(report, reportTransactions, currentUserAccountID, reportMetadata, policy)) {
reportsToApprove.push(report);
}
if (isPrimaryPayAction(report, currentUserAccountID, login, bankAccountList, policy, reportNameValuePair)) {
reportsToPay.push(report);
}
// Only compute reportActions when needed for export check
const reportActions = Object.values(allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`] ?? []);
if (isExportAction(report, login, policy, reportActions)) {
reportsToExport.push(report);
}Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5de32919e9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const reportActions = Object.values(allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`] ?? []); | ||
| const reportTransactions = transactionsByReportID[report.reportID] ?? []; | ||
| const reportMetadata = allReportMetadata?.[`${ONYXKEYS.COLLECTION.REPORT_METADATA}${report.reportID}`]; | ||
| const shouldShowInSubmitTodo = isOpenExpenseReport(report) && isCurrentUserSubmitter(report) && reportTransactions.length > 0 && !isArchivedReport(reportNameValuePair); |
There was a problem hiding this comment.
Restore pending-submit guard for submit todos
The new shouldShowInSubmitTodo predicate now classifies submit todos using only open/owner/has-transactions/not-archived checks, which drops the pending-submit protections that isSubmitAction previously enforced (notably hasPendingDEWSubmit in src/libs/ReportPrimaryActionUtils.ts). In DEW-enabled policies, reports that are already mid-submit can now reappear in To do → Submit, so users see non-actionable items and incorrect submit counts while submission is still in flight.
Useful? React with 👍 / 👎.
trjExpensify
left a comment
There was a problem hiding this comment.
Looking at the video evidence for this one on Web/Desktop doesn't seem to confirm or deny the bug fix. Could you please make sure to capture the bug fix?
As I understand the bug...
- User goes to the Submit tab
- They have a draft report to submit
- User scans a second receipt, it's added to that draft report
- They're navigated to Reports > Expenses upon taking that action to see feedback that it was added
- User clicks on the Submit tab while the receipt is scanning
- The draft report is no longer shown while the receipt is scanning
- The receipt scan completes and the draft report is shown again
So the bug we're addressing here is with steps 6&7. If there are eligible expenses to submit on the report, continue showing the report in the Submit tab as it is eligible to submit. If you submit a report with any scanning expenses on it, we should already be automatically moving those scanning expenses off the report on submission - and we don't show a submit button if all expenses on the report are still scanning.
CC: @JS00001 @luacmartins for vis btw!
@JS00001 @luacmartins |
|
That seems like the bug yes, from the original issue:
|
|
I agree with the above. We currently return false here if not all transactions are complete (which is the case when the receipt is scanning). We should update that logic to check if at least one transaction is complete. |
|
Hi @ZhenjaHorbach, what should I do next? |
|
Hi @luacmartins, @ZhenjaHorbach What should I do next? |
|
Oh |
|
Hey, I noticed you changed If you want to automatically generate translations for other locales, an Expensify employee will have to:
Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running: npx ts-node ./scripts/generateTranslations.ts --helpTypically, you'd want to translate only what you changed by running |
|
Hi @ZhenjaHorbach I updated my PR. |
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
@annaweber830 |
|
@annaweber830 what's the latest update on this one? |
|
Hi @luacmartins I already updated PR. |
Nice then @annaweber830 |
|
Hi @ZhenjaHorbach I will fix lint issue. |
|
@annaweber830 what's the latest here? |
|
@ZhenjaHorbach I updated PR. |
|
Thanks @annaweber830. @ZhenjaHorbach let's review this one please |
|
Reviewing! |
| const reportMetadata = allReportMetadata?.[`${ONYXKEYS.COLLECTION.REPORT_METADATA}${report.reportID}`]; | ||
|
|
||
| if (isSubmitAction(report, reportTransactions, reportMetadata, policy, reportNameValuePair, undefined, login, currentUserAccountID)) { | ||
| const shouldShowInSubmitTodo = isOpenExpenseReport(report) && isCurrentUserSubmitter(report) && reportTransactions.length > 0 && !isArchivedReport(reportNameValuePair); |
There was a problem hiding this comment.
Instead of creating a separate condition, can we please update it here and just call isSubmitAction as we used to? So that the issue is fixed everywhere?
trjExpensify
left a comment
There was a problem hiding this comment.
@ZhenjaHorbach video here shows the bug being resolved: #82042 (comment)
@annaweber830 I think you can improve the test steps to cut out the irrelevant navigation from the Inbox and navigation.
- Create a workspace and scan receipt to workspace chat
- Navigate to Reports tab
- Choose type: Expense report, To do Submit
- Drag and drop an image file to Scan receipts zone
- Select Category and click on Create expense
- Observe reports page and wait a time
- After creating scan expense from reports, the existing report in filter should still display
I'd suggest...
- Go to the Reports page
- Create an expense
- Verify the "Submit" todo has a (1) counter in the LHN
- Drag and drop a receipt to create another expense
- Verify you're navigated to the "Expenses" LHN page
- Verify the "Submit" todo still has a (1) counter in the LHN
- Click on the "Submit" LHN page while the receipt is still scanning
- Verify the draft report remains visible
|
@annaweber830 bump on my comment above #82042 (comment) |
|
@luacmartins Sorry I updated PR. |
|
✋ 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/luacmartins in version: 9.3.61-0 🚀
Bundle Size Analysis (Sentry): |
|
No help site changes are required for this PR. The changes are purely internal bug fixes to |
|
🚀 Deployed to production by https://github.com/marcaaron in version: 9.3.61-4 🚀
|
Explanation of Change
Fixed Issues
$ #80576
PROPOSAL: #80576 (comment)
Tests
Offline tests
Same as test
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
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: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-02-10.at.11.51.32.AM.mp4