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
[$250] Duplicate expense-There is no duplicate expense option until reselecting all expense #87599
BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors
Version Number: v9.3.58-0 Reproducible in staging?: Yes Reproducible in production?: N/A - new feature, doesn't exist in prod If this was caught during regression testing, add the test name, ID and link from BrowserStack:#84657 Email or phone of affected tester (no customers):testpayment935@gmail.com Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: Windows 11 pro /Chrome App Component: Money Requests
Action Performed:
Navigate to staging.new.expensify.com
Create an expense and duplicate until it become 100 or more expense in report page
Submit and approve all in the WS chat ( Keep all expense in duplicate review page
After the report loads correctly, go to report page and select all
Note only 50 of the expense are loaded
Click "select all matching item" scroll down to include the remining expense
Click drop down of all matching item selected
Note there is no duplicate expense option
Unselect all expense and select again
Expected Result:
In step 8 there should be a duplicate expense option
Actual Result:
In step 8 there is no duplicate expense option until unselect and select all the expenses again
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
Identify the pull request that introduced this issue and revert it.
Investigation Summary - Classification: Frontend bug. Causing PR: 84657 "[Duplicate Expense] Allow bulk duplication." by @Krishna2323 (High confidence). Recommendation: REVERT. The causing PR introduced the bulk duplicate option but its visibility check fails when the report has more than 50 expenses and select-all-matching-items is used, because not all selected transactions are loaded in the Onyx store at that time. Assigned: @Krishna2323 (PR author), @JS00001@situchan (approving reviewers). Labels: DeployBlockerCash kept (frontend bug in App repo). Root Cause: shouldShowBulkDuplicateOption uses Array.every() against allTransactions (Onyx in-memory store). When select-all-matching-items selects more transaction IDs than are loaded in the current page (50 per page), the unloaded transactions are absent from allTransactions causing every() to return false and isDuplicateOptionVisible to be false - hiding the duplicate option. Evidence: Bug is staging-only and was introduced by PR 84657 (merged 2026-04-09). The hook useSelectedTransactionsActions.ts lines 158-195 builds selectedTransactionsForDuplicate and calls shouldShowBulkDuplicateOption. When the paginated list only loads 50 items but 100+ are selected, the unloaded transaction IDs fail the lookup. The workaround of deselect-and-reselect works because it only selects the visible 50, which are all in Onyx.
This means the "Review duplicates" option (added at line 1328) is never reached. When the user deselects and reselects, clearSelectedTransactions resets areAllMatchingItemsSelected to false, so the early return is skipped and the full set of bulk actions (including duplicates) is computed.
What changes do you think we should make in order to solve the problem?
The early return at useSearchBulkActions.ts:1027-1029 should be updated to also include bulk action options that can work with the "all matching" selection — specifically the "Duplicate expense" option. The isDuplicateOptionVisible check and the duplicate option should be evaluated before the early return, so that when areAllMatchingItemsSelected is true, the returned array includes both Export and (if applicable) Duplicate.
What alternative solutions did you explore?
An alternative would be to remove the early return entirely and instead guard each individual bulk action that requires full client-side data. However, this would be a larger refactor with more risk. The targeted fix of moving the duplicate option evaluation before the early return is simpler and lower risk.
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.
@situchan@JS00001 this affects all bulk actions, not just duplicate. It's a pre-existing behavior that our PR didn't introduce. The flag areAllMatchingItemsSelected is a separate concept from "every visible item is checked" and doesn't auto-resolve when all items become loaded.
changed the title [-]Duplicate expense-There is no duplicate expense option until reselecting all expense[/-][+][$250] Duplicate expense-There is no duplicate expense option until reselecting all expense[/+]on Apr 10, 2026
Yes, this is intentional. The early return at useSearchBulkActions.ts:1027-1029 restricts bulk actions to Export only when areAllMatchingItemsSelected is true — and this applies to all non-export bulk actions (approve, pay, delete, hold, merge, etc.), not just duplicate.
Why: "Select all matching items" logically selects items on unloaded pages (only the first 50 are loaded client-side). Export works because it sends the search query (jsonQuery) to the server for server-side resolution. Every other bulk action requires per-transaction client-side data (action, canHold, canApprove, etc.) that doesn't exist for unloaded items.
Supporting evidence
The export path at line 356-364 sends the full jsonQuery to the server with empty ID lists when areAllMatchingItemsSelected is true
Post-early-return code at line 1031+ iterates selectedTransactions and checks per-transaction properties — this requires loaded transaction objects
Supporting other bulk actions for "select all matching" would require server-side implementations similar to export — that would be a feature request, not a bug fix.
Please re-state the problem that we are trying to solve in this issue.
When handling duplicate expenses, the duplicate-expense action is missing right after selecting the report, and only appears after reselecting the report.
What is the root cause of that problem?
The bulk-action availability for duplicate handling depends on selected transactions/reports from search results, but those results can briefly become empty during the report-selection refresh cycle.
SearchContext returns snapshot-based search data for non to-do searches, so transient empty snapshots can occur while the selected report context is changing.
// If viewing a to-do search, use live data from useTodos, otherwise return the snapshot data
// We do this so that we can show the counters for the to-do search results without visiting the specific to-do page, e.g. show `Approve [3]` while viewing the `Submit` to-do search.
In useSearchBulkActions, option eligibility for all-selected mode should use the last non-empty result set. Without that fallback, the merge/duplicate action disappears until results repopulate.
What changes do you think we should make in order to solve the problem?
Keep duplicate/merge eligibility tied to a stable cached non-empty search result set during short refresh windows.
Use the cached selected reports/transactions when areAllMatchingItemsSelected is true and current snapshot is temporarily empty.
Ensure action-option computation is deterministic across the report-selection transition so users do not lose the duplicate-expense option.
Add regression coverage for the sequence: select report -> immediate duplicate action check -> no reselect needed.
What alternative solutions did you explore? (Optional)
An alternative is delaying menu rendering until search results repopulate, but that adds UI latency and can feel unresponsive. Keeping the action state stable with cached non-empty results is simpler and preserves UX continuity.
BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors
Activity
melvin-bot commentedon Apr 10, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #84657
melvin-bot commentedon Apr 10, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon Apr 10, 2026
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
OSBotify commentedon Apr 10, 2026
Investigation Summary - Classification: Frontend bug. Causing PR: 84657 "[Duplicate Expense] Allow bulk duplication." by @Krishna2323 (High confidence). Recommendation: REVERT. The causing PR introduced the bulk duplicate option but its visibility check fails when the report has more than 50 expenses and select-all-matching-items is used, because not all selected transactions are loaded in the Onyx store at that time. Assigned: @Krishna2323 (PR author), @JS00001 @situchan (approving reviewers). Labels: DeployBlockerCash kept (frontend bug in App repo). Root Cause: shouldShowBulkDuplicateOption uses Array.every() against allTransactions (Onyx in-memory store). When select-all-matching-items selects more transaction IDs than are loaded in the current page (50 per page), the unloaded transactions are absent from allTransactions causing every() to return false and isDuplicateOptionVisible to be false - hiding the duplicate option. Evidence: Bug is staging-only and was introduced by PR 84657 (merged 2026-04-09). The hook useSelectedTransactionsActions.ts lines 158-195 builds selectedTransactionsForDuplicate and calls shouldShowBulkDuplicateOption. When the paginated list only loads 50 items but 100+ are selected, the unloaded transaction IDs fail the lookup. The workaround of deselect-and-reselect works because it only selects the visible 50, which are all in Onyx.
MelvinBot commentedon Apr 10, 2026
Proposal
What is the root cause of that problem?
When a user clicks "Select all matching items," the flag
areAllMatchingItemsSelectedis set totrue(SearchContext.tsx:105). InuseSearchBulkActions.ts, the bulk actions computation early-returns with only the Export option when this flag istrue:This means the "Review duplicates" option (added at line 1328) is never reached. When the user deselects and reselects,
clearSelectedTransactionsresetsareAllMatchingItemsSelectedtofalse, so the early return is skipped and the full set of bulk actions (including duplicates) is computed.What changes do you think we should make in order to solve the problem?
The early return at
useSearchBulkActions.ts:1027-1029should be updated to also include bulk action options that can work with the "all matching" selection — specifically the "Duplicate expense" option. TheisDuplicateOptionVisiblecheck and the duplicate option should be evaluated before the early return, so that whenareAllMatchingItemsSelectedis true, the returned array includes both Export and (if applicable) Duplicate.What alternative solutions did you explore?
An alternative would be to remove the early return entirely and instead guard each individual bulk action that requires full client-side data. However, this would be a larger refactor with more risk. The targeted fix of moving the duplicate option evaluation before the early return is simpler and lower risk.
Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.situchan commentedon Apr 10, 2026
This feature is gated behind production so we can demote.
3 remaining items
Krishna2323 commentedon Apr 10, 2026
@situchan @JS00001 this affects all bulk actions, not just duplicate. It's a pre-existing behavior that our PR didn't introduce. The flag
areAllMatchingItemsSelectedis a separate concept from "every visible item is checked" and doesn't auto-resolve when all items become loaded.Monosnap.screencast.2026-04-10.19-31-25.mp4
situchan commentedon Apr 10, 2026
Agree. I also noticed this while testing PR but not reported because it's existing behavior.
JS00001 commentedon Apr 10, 2026
Cool, lets make it external then
melvin-bot commentedon Apr 10, 2026
Current assignees @Krishna2323 and @situchan are eligible for the External assigner, not assigning anyone new.
melvin-bot commentedon Apr 10, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022042606189679731536
[-]Duplicate expense-There is no duplicate expense option until reselecting all expense[/-][+][$250] Duplicate expense-There is no duplicate expense option until reselecting all expense[/+]Krishna2323 commentedon Apr 10, 2026
@JS00001 I don't think this needs a fix, seems intentional. @MelvinBot can you confirm?
MelvinBot commentedon Apr 10, 2026
Yes, this is intentional. The early return at
useSearchBulkActions.ts:1027-1029restricts bulk actions to Export only whenareAllMatchingItemsSelectedis true — and this applies to all non-export bulk actions (approve, pay, delete, hold, merge, etc.), not just duplicate.Why: "Select all matching items" logically selects items on unloaded pages (only the first 50 are loaded client-side). Export works because it sends the search query (
jsonQuery) to the server for server-side resolution. Every other bulk action requires per-transaction client-side data (action,canHold,canApprove, etc.) that doesn't exist for unloaded items.Supporting evidence
jsonQueryto the server with empty ID lists whenareAllMatchingItemsSelectedis trueselectedTransactionsand checks per-transaction properties — this requires loaded transaction objectsSearchContext.tsx:105and specifically represents items beyond the loaded view, as noted in the comment atSearch/index.tsx:933-934Supporting other bulk actions for "select all matching" would require server-side implementations similar to export — that would be a feature request, not a bug fix.
JS00001 commentedon Apr 10, 2026
Oh yeah, I misread this one, this is expected, sorry
KJ21-ENG commentedon Apr 10, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When handling duplicate expenses, the duplicate-expense action is missing right after selecting the report, and only appears after reselecting the report.
What is the root cause of that problem?
The bulk-action availability for duplicate handling depends on selected transactions/reports from search results, but those results can briefly become empty during the report-selection refresh cycle.
SearchContextreturns snapshot-based search data for non to-do searches, so transient empty snapshots can occur while the selected report context is changing.App/src/components/Search/SearchContext.tsx
Lines 96 to 107 in 1d43910
In
useSearchBulkActions, option eligibility for all-selected mode should use the last non-empty result set. Without that fallback, the merge/duplicate action disappears until results repopulate.App/src/hooks/useSearchBulkActions.ts
Lines 95 to 106 in 1d43910
App/src/hooks/useSearchBulkActions.ts
Lines 206 to 223 in 1d43910
App/src/hooks/useSearchBulkActions.ts
Lines 281 to 300 in 1d43910
What changes do you think we should make in order to solve the problem?
areAllMatchingItemsSelectedis true and current snapshot is temporarily empty.What alternative solutions did you explore? (Optional)
An alternative is delaying menu rendering until search results repopulate, but that adds UI latency and can feel unresponsive. Keeping the action state stable with cached non-empty results is simpler and preserves UX continuity.