You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-11-06] [$175] Spend - Select all count is stale after submitting a report #102298
The "N selected" count shows the old, stale value.
Video
Mac-Chrome.mp4
Notes
It isn't confirmed yet whether the PR above caused this or whether it happened before. That PR changed how selection data is capped for the live to-do searches, so check it first.
It isn't confirmed yet whether the PR above caused this or whether it happened before. That PR changed how selection data is capped for the live to-do searches, so check it first.
Not related with #100941. It's repro on both staging and prod
Please re-state the problem that we are trying to solve in this issue.
In Spend > Reports (to-do search), after selecting all items, deselecting all, and submitting a report, re-selecting all displays the previous stale "N selected" count instead of decrementing to reflect the submitted report.
What is the root cause of that problem?
In live to-do searches (isTodoSearch), results are built dynamically from live Onyx data via useTodoSearchResults.
In src/hooks/useTodoSearchResults.ts (lines 18–54), TodoMetadata and computeMetadata calculate:
count (total transactions across all matching reports)
total (dollar sum in cents)
currency
However, it never calculates or returns reportCount (reports.length).
In src/components/Search/SearchResultsProvider.tsx (lines 56–61), when constructing searchInfo for live to-do data:
Because reportCount is omitted from searchInfo, it falls back to snapshotSearchResults?.search?.reportCount (the server snapshot cached at page load).
When a report is submitted, useTodoSearchResults reactively updates from Onyx collections and removes the submitted report from reports. However, currentSearchResults.search.reportCount remains stuck on the stale server snapshot value.
In src/components/Search/SearchBulkActionsButton.tsx (lines 182–198), for isExpenseReportType:
The selection count directly reads allMatchingReportsCount (currentSearchResults?.search?.reportCount). Because SearchResultsProvider never synchronized reportCount from the live reports array, selectedBulkActionsCount continues to display the stale initial snapshot report count rather than the decremented live count.
What changes do you think we should make in order to solve the problem?
Expose reportCount in TodoMetadata (src/hooks/useTodoSearchResults.ts):
Add reportCount: number to TodoMetadata:
typeTodoMetadata={/** Total number of transactions across all reports */count: number;/** Total number of matching reports */reportCount: number;/** Sum of all report totals (in cents) */total: number;/** Currency of the first report, used as reference currency */currency: string|undefined;};
Propagate reportCount in SearchResultsProvider.tsx (src/components/Search/SearchResultsProvider.tsx):
Pass reportCount from liveData.metadata into searchInfo:
What alternative solutions did you explore? (Optional)
Re-fetching the server snapshot after submitting a report. This was rejected because to-do searches are designed to run optimistically off live Onyx data without waiting for network round-trips. Properly providing reportCount: reports.length from live metadata ensures immediate, consistent UI updates across all tabs.
This should be more than 50. I thought it is repro with more than 25
From the video in OP, it doesn't look like bug.
In LHN, todo count is 50+ first and after submitting a report, it becomes 50.
So the Select all count matches LHN badge
As you can see on the vid there is inconsistency with 50 > and < so its a bug
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Regression Test Proposal
Precondition:
An account with more than 50 draft reports in a workspace, each with at least one expense.
Test:
Go to Spend > Drafts.
Press the checkbox at the top of the list and choose "Select all".
Note the number in the "N selected" bar. This is N.
changed the title [-][$175] Spend - Select all count is stale after submitting a report[/-][+][Due for payment 2026-11-06] [$175] Spend - Select all count is stale after submitting a report[/+]on Nov 6, 2026
Activity
TaduJR commentedon Sep 25, 2026
Not related with #100941. It's repro on both staging and prod
Fix: Keep reportCount updated from live Onyx metadata in SearchResult…
ashusatyarthi-wq commentedon Sep 25, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
In Spend > Reports (to-do search), after selecting all items, deselecting all, and submitting a report, re-selecting all displays the previous stale "N selected" count instead of decrementing to reflect the submitted report.
What is the root cause of that problem?
In live to-do searches (
isTodoSearch), results are built dynamically from live Onyx data viauseTodoSearchResults.In
src/hooks/useTodoSearchResults.ts(lines 18–54),TodoMetadataandcomputeMetadatacalculate:count(total transactions across all matching reports)total(dollar sum in cents)currencyHowever, it never calculates or returns
reportCount(reports.length).In
src/components/Search/SearchResultsProvider.tsx(lines 56–61), when constructingsearchInfofor live to-do data:Because
reportCountis omitted fromsearchInfo, it falls back tosnapshotSearchResults?.search?.reportCount(the server snapshot cached at page load).When a report is submitted,
useTodoSearchResultsreactively updates from Onyx collections and removes the submitted report fromreports. However,currentSearchResults.search.reportCountremains stuck on the stale server snapshot value.In
src/components/Search/SearchBulkActionsButton.tsx(lines 182–198), forisExpenseReportType:The selection count directly reads
allMatchingReportsCount(currentSearchResults?.search?.reportCount). BecauseSearchResultsProvidernever synchronizedreportCountfrom the livereportsarray,selectedBulkActionsCountcontinues to display the stale initial snapshot report count rather than the decremented live count.What changes do you think we should make in order to solve the problem?
Expose
reportCountinTodoMetadata(src/hooks/useTodoSearchResults.ts):Add
reportCount: numbertoTodoMetadata:In
computeMetadata(reports, ...):Propagate
reportCountinSearchResultsProvider.tsx(src/components/Search/SearchResultsProvider.tsx):Pass
reportCountfromliveData.metadataintosearchInfo:Pre-tested Branch:
The fix is committed and tested on:
ashusatyarthi-wq/App:fix/stale-select-all-count-102298(Commit4284404c5253a550000e49116e176288c26188a5).What alternative solutions did you explore? (Optional)
Re-fetching the server snapshot after submitting a report. This was rejected because to-do searches are designed to run optimistically off live Onyx data without waiting for network round-trips. Properly providing
reportCount: reports.lengthfrom live metadata ensures immediate, consistent UI updates across all tabs.ashusatyarthi-wq commentedon Sep 25, 2026
Contributor details
Your Expensify account email: ashusatyarthi@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~010e53044b5828fe60
melvin-bot commentedon Sep 25, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
TaduJR commentedon Sep 28, 2026
I can help with review if C+ is needed since I reported the issue and have the context. LMK 👍
cc @mountiny
mkhutornyi commentedon Sep 28, 2026
From the video in OP, it doesn't look like bug.
In LHN, todo count is 50+ first and after submitting a report, it becomes 50.
So the Select all count matches LHN badge
mkhutornyi commentedon Sep 28, 2026
Do you have clear video? The video in OP isn't clear.
TaduJR commentedon Sep 28, 2026
Mac-Chrome.mp4
This should be more than 50. I thought it is repro with more than 25
As you can see on the vid there is inconsistency with 50 > and < so its a bug
melvin-bot commentedon Sep 28, 2026
Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
melvin-bot commentedon Sep 30, 2026
Huh... This is 4 days overdue. Who can take care of this?
57 remaining items
TaduJR commentedon Nov 6, 2026
Follow up fixed on main.
TaduJR commentedon Nov 6, 2026
Contributor+ Checklist:
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to the comment on the PR: Label Reports tab "Select all" with matching-report count #99689 (comment)
Link to the comment on the Issue:
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Regression Test Proposal
Precondition:
Test:
Do we agree 👍 or 👎
[-][$175] Spend - Select all count is stale after submitting a report[/-][+][Due for payment 2026-11-06] [$175] Spend - Select all count is stale after submitting a report[/+]melvin-bot commentedon Nov 6, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)mallenexpensify commentedon Nov 7, 2026
Payment Summary
Contributor+: @TaduJR due $175 via Upwork
@TaduJR can you please accept the job below? Please reply here and tag me once you have.
https://www.upwork.com/jobs/~022118857608614079621
TaduJR commentedon Nov 7, 2026
Offer Accepted @mallenexpensify
But the offer is $250, the issue was created after Sept 19, so the correct amount is $175.
Thanks!
mallenexpensify commentedon Nov 9, 2026
@TaduJR , thanks for pointing it out, normally I catch the different but was sidetracked when paying.
Can you accept the refund request for $75 si the total will be $175? Thx
https://www.upwork.com/jobs/~022118857608614079621
TaduJR commentedon Nov 9, 2026
@mallenexpensify
This link is not working.
Also going to the workroom and trying to refund requires invoice and does the full refund.
Should we deduct from another issue payment like #101694 and you can pay $100? wdyt?
TaduJR commentedon Nov 9, 2026
@mallenexpensify
Got it. Found the refund request in Upwork Chat. Sorry first time 😁
Please check the request I approved the refund.
Thanks!
mallenexpensify commentedon Nov 9, 2026
Thanks @TaduJR , confirming the refund was received. Thanks for pointing out it was in the chat too, I'll try to remember that.