Repository navigation
Keep non-reimbursable-only reports out of Ready to pay before their expenses load - #105618
Conversation
…to pay before their expenses load Co-authored-by: Jayesh Mangwani <jayeshmangwani@users.noreply.github.com>
Co-authored-by: Jayesh Mangwani <jayeshmangwani@users.noreply.github.com>
|
I opened this PR from an upstream branch because I can't push to your fork. To take over this branch and push updates, run: Then close this PR and open a new one from your fork. |
|
🤖 Web test steps verification results: Ready to pay correctly excludes the non-reimbursable-only approved reports, and opening one of them and going back doesn't change the count. However, I couldn't reach the state this PR fixes, where the reports' expenses haven't loaded yet: I created the reports in this session, so their expenses were already loaded, and the tester can't clear local storage or sign out and back in.
|
|
@MelvinBot , please add the Tests, QA, and Offline test sections and select all the checklist items. I can’t edit those. I’ll add the videos to the Reviewer checklist, so please check the corresponding boxes in the PR Author checklist. |
|
@MelvinBot please check this comment #105618 (comment) |
|
@MelvinBot could you please add the Tests section? |
|
@MelvinBot , please add the Tests, QA, and Offline test sections and select all the checklist items. I can’t edit those. I’ll add the videos to the Reviewer checklist, so please check the corresponding boxes in the PR Author checklist. |
|
Tests, QA Steps, and Offline tests now contain proposed testing instructions. Human results and sign-off remain pending. All PR Author checklist boxes were already selected, so I left them unchanged. Those selections do not verify the outstanding unloaded-transaction, offline, High Traffic, or all-platform tests; the promised reviewer videos still need to be added. |
|
@MelvinBot, could you please clean up the Tests and QA Tests sections and update them with the test below? There’s currently too much vague information in those sections. Also, please add N/A to the offline test section. ### Prerequisites
1. Log in with two users: User A and User B. Ideally, User A should be a high-traffic account.
2. User A should have a workspace with User B added as a member.
3. Ensure that Workflows and Payments are enabled in the workspace, with User A assigned as the Payer.
### Steps to reproduce
1. User B creates a few non-reimbursable expenses.
2. User A approves the expenses.
3. Verify that approving the reports does not increase the `Ready to pay` count on the Spend tab.
4. Log out User A or clear the data using **Clear cache and restart**.
5. Open the Spend page and check the `Ready to pay` section and its count.
6. Open one of the reports containing only non-reimbursable expenses, then navigate back.
7. Verify that reports containing only non-reimbursable expenses never appear in the `Ready to pay` section.
### Alternative scenario
We can also test with three users:
- **User A:** Workspace owner
- **User B:** Approver and Payer
- **User C:** Submitter |
|
Updated Tests with your prerequisites, seven steps, and three-user alternative. QA Steps now says “Same as Tests,” Offline tests is “N/A,” and the duplicate vague test plan has been removed. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid.movAndroid: mWeb Chromemweb-chrome.moviOS: HybridAppios.moviOS: mWeb Safarimweb-safari.movMacOS: Chrome / SafariThis video shows the side-by-side behavior for the same user on Staging and with this PR. On Staging, the count is incorrect and decreases after opening a child expense. web.mov |
|
@MelvinBot Please mark this PR as "Ready for review" , it looks good to go. |
|
Marked this PR as Ready for review. |
|
@jayeshmangwani 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] |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #105413 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6bc93c3e23
ℹ️ 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".
| if (transactions.length === 0) { | ||
| return hasOnlyNonReimbursableTotal(report); |
There was a problem hiding this comment.
Keep unsettled reimbursements in the pay queue
When an approved report combines non-reimbursable spend with an unloaded reimbursable SmartScan expense whose amount is not known yet, the report totals still look like reimbursableTotal: 0 with a nonzero non-reimbursable total. This empty-transaction branch therefore marks the report pay-optional and removes it from the Pay to-do, LHN badge, and Search Pay action; once its transactions load, the existing unsettled-expense check reverses that decision, so a payer may not discover the reimbursement unless they independently open or fetch the report. Avoid trusting this totals-only classification until the absence of scanning or otherwise unsettled reimbursable expenses can be established.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The suggestion identifies a real classification gap, but the P1 impact is not yet demonstrated.
- The unloaded-transaction fallback treats zero reimbursable totals as pay-optional without checking unsettled expenses. The pending-total guard checks an optimistic-update marker, not SmartScan state, so it does not resolve that ambiguity.
- Reachability needs confirmation: the primary Approve action blocks scanning receipts, but the approval eligibility check does not exclude a mixed settled/scanning report through its all-expenses-scanning guard. Backend acceptance of that scenario remains unverified.
- Opening the report is not necessarily required for recovery: to-do counts subscribe to report and transaction updates. Updated nonzero reimbursable totals would restore pay eligibility; actual scan-completion delivery in this scenario still needs verification.
Recommendation: Validate approval and scan-completion recovery for the mixed case. If reachable, preserve fail-closed behavior until complete transactions or an authoritative report-level signal rules out unsettled reimbursements. Add regression coverage for unloaded → loaded → scan-completed transitions; the new tests do not cover them.
No code changes made or runtime tests run for this review.
|
🚧 joekaufmanexpensify has triggered a test Expensify/App build. You can view the workflow run here. |
This comment has been minimized.
This comment has been minimized.
joekaufmanexpensify
left a comment
There was a problem hiding this comment.
Tested in the customer account who was originally experiencing this issue and confirmed the fix is working well on the ad hoc build.
|
@marcochavezf, the PR is good to go for merging. |
|
All checks pass, and this PR passed internal engineering review, so I'm going to go ahead with merging it. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 joekaufmanexpensify has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/joekaufmanexpensify in version: 9.5.41-0 🚀
|
|
No help site update needed — this fixes non-reimbursable-only reports incorrectly appearing as payable before their expenses load, restoring expected behavior without adding a feature or making existing guidance incorrect. |
|
🚀 Deployed to production by https://github.com/marcaaron in version: 9.5.41-2 🚀
Bundle Size Analysis (Sentry): |






Explanation of Change
Approved reports that contain only non-reimbursable expenses showed up in Ready to pay until their transactions loaded. When you opened one, it dropped out of the list and the count went down by one.
The cause is that
isPayOptional()decided only from loaded transactions. With no transactions in Onyx, bothhasOnlyNonReimbursableTransactions()andhasSettledZeroReimbursableSpend()returnfalse, so the report counted as payable. The report object already had the right answer in its totals (reimbursableTotal: 0, non-zerononReimbursableTotal).This PR changes
isPayOptional()insrc/libs/ReportUtils.ts:hasOnlyNonReimbursableTotal(). That helper returnstruefor an expense report whose total is loaded and not pending, with zero reimbursable spend and non-zero non-reimbursable spend.isReportTotalLoadedAndSettled().The fix is in
isPayOptional(), so every caller now behaves the same way before transactions load: the Pay to-do, the LHN Pay badge, and the Search row Pay action.One edge case for reviewers: an approved report with card expenses and a reimbursable receipt that is still scanning has a $0 reimbursable total. Before its transactions load, it is now treated as pay-optional. After they load, the existing fail-closed check treats it as payable. This is rare, and the totals give no way to detect a scanning receipt.
AI tests run (by MelvinBot):
tests/unit/ReportUtilsTest.ts(isPayOptional) andtests/unit/TodosUtilsTest.ts(Pay bucket). The new to-do test fails without the fix and passes with it.ReportUtilsTest,TodosUtilsTest,Search/SearchUIUtilsTest,Search/SearchUIUtils.test,hooks/useTodoSearchResultsTest,SidebarUtilsTest,ReportPrimaryActionUtilsTest,ui/SearchPageTest(2,609 tests).npm run typecheck,npm run lint-changed,npm run spell-changed,oxfmt(no formatting changes).npm testsuite, which took longer than 10 minutes, and manual UI testing.Fixed Issues
$ #105413
PROPOSAL: #105413 (comment)
Tests
Prerequisites
Steps to reproduce
Ready to paycount on the Spend tab.Ready to paysection and its count.Ready to paysection.Alternative scenario
We can also test with three users:
User A: Workspace owner
User B: Approver and Payer
User C: Submitter
Verify that no errors appear in the JS console
Offline tests
N/A
QA Steps
Same as Tests, including the prerequisites and alternative three-user scenario.
PR Author Checklist
Checklist marked at
jayeshmangwani's explicit request; these selections are not additional test evidence or human sign-off. The unloaded-transaction UI regression, offline testing, High Traffic testing, and full platform coverage remain unverified. The human co-author must still complete Tests and QA with actual results and attach the promised videos.### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)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.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