Repository navigation
[Payment due @jayeshmangwani] Delete every match from Select all - #104444
Conversation
Codex Review Summary: ✅ CompletedThis 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. |
|
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 bun ./scripts/generateTranslations.ts --helpTypically, you'd want to translate only what you changed by running |
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.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 974a375c4c
ℹ️ 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".
| : selectedTransactionsKeys.some((id) => | ||
| shouldShowDeleteOption({[id]: selectedTransactions[id]}, currentSearchResults?.data, accountID, rules, cardList, [], queryJSON?.type), | ||
| ); | ||
| if (!isOffline && isExpenseOrReportSearch && hasLoadedDeletableItem) { |
There was a problem hiding this comment.
Keep Delete available when selected matches are unloaded
When Select all has more results, deselecting every loaded row intentionally leaves areAllMatchingItemsSelected true while moving those rows to excludedTransactions; both selected collections are then empty even though unloaded matches remain selected. This loaded-item gate therefore removes Delete and makes the new server-side delete impossible for that valid exclusion state (and similarly when only a later page contains a deletable item), so availability needs to account for remaining all-matching selections rather than require a loaded selected row.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
this matches Hold, Unhold and Reject under Select all, they're also offered from the loaded rows
| return; | ||
| } | ||
| // "Select all" can cover more than is loaded, so hand the search query to the backend to delete every match. | ||
| if (areAllMatchingItemsSelected) { |
There was a problem hiding this comment.
Warn before deleting unloaded pending expenses
When an all-matching expense selection spans unloaded pages, hasSomePendingExpenses above only scans loaded selectedTransactions. If a deletable, reported BYOC pending expense exists only on an unloaded page, the confirmation shown before this branch uses the ordinary delete prompt, but this full-query request still deletes that expense, so the user never receives the existing warning that it may be imported again; use an all-matching-safe warning or backend-derived pending metadata before confirming.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
we only know about the loaded expenses here, so the warning can't cover the unloaded ones
# Conflicts: # src/hooks/useSearchBulkActions.ts # src/libs/API/parameters/index.ts # src/libs/API/types.ts # src/libs/actions/Search.ts # tests/unit/hooks/useSearchBulkActionsTest.ts
|
@mkhutornyi lets get this reviewed on Monday please, hope you enjoy your weekend, thanks |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppios.mp4iOS: mWeb SafariMacOS: Chrome / Safariexpense.movreport.movScreen.Recording.2026-11-23.at.1.48.15.PM.mov |
|
|
||
| jest.mock('@libs/SearchUIUtils', () => ({ | ||
| ...jest.requireActual<typeof SearchUIUtils>('@libs/SearchUIUtils'), | ||
| shouldShowDeleteOption: jest.fn(() => true), |
There was a problem hiding this comment.
The rule for when Delete appears is untested
This always returns true for every describe in this file, so no test can cover "one deletable loaded item shows Delete, none hides it".
Use a controllable mockShouldShowDeleteOption, like useSearchBulkActionsDeleteTest.ts, and add both cases.
| }); | ||
|
|
||
| // Then the search is handed to the backend to delete the reports, not looped per loaded report | ||
| expect(queueBulkDeleteReports).toHaveBeenCalledWith(expect.any(String)); |
There was a problem hiding this comment.
No test proves a deselected report is left out of the delete
This assertion only checks expect.any(String), and no Reports test has a deselected row.
A bug that dropped the exclusion would delete that report and still pass.
Add that case with the existing expectQueryToExcludeReport helper, like the Approve and Submit tests.
| allMatchingOptions.push({ | ||
| icon: expensifyIcons.Trashcan, | ||
| text: translate('search.bulkActions.delete'), | ||
| value: CONST.SEARCH.BULK_ACTION_TYPES.DELETE, | ||
| sentryLabel: CONST.SENTRY_LABEL.SEARCH.BULK_ACTIONS_DELETE, | ||
| shouldCloseModalOnSelect: true, | ||
| onSelected: handleDeleteSelectedTransactions, | ||
| }); |
There was a problem hiding this comment.
The Delete option is duplicated
This copies the existing one:
App/src/hooks/useSearchBulkActions.ts
Lines 3791 to 3798 in 9ee9170
Every other Select all action shares one object, such as
holdOption.
Dxtract a deleteOption and use it in both places.
| const shouldShowDeleteOptionForAllMatchingItems = | ||
| canQueueDelete && | ||
| (selectedReports.length && isExpenseReportType | ||
| ? selectedReports.some((report) => | ||
| shouldShowDeleteOption(selectedTransactions, currentSearchResults?.data, accountID, rules, personalDetails, cardList, allReportActions, [report], queryJSON?.type), | ||
| ) | ||
| : selectedTransactionsKeys.some((id) => | ||
| shouldShowDeleteOption( | ||
| {[id]: selectedTransactions[id]}, | ||
| currentSearchResults?.data, | ||
| accountID, | ||
| rules, | ||
| personalDetails, | ||
| cardList, | ||
| allReportActions, | ||
| [], | ||
| queryJSON?.type, | ||
| ), | ||
| )); |
There was a problem hiding this comment.
The Delete check is hard to read and repeats a full scan
This check puts two .some() calls with nine positional arguments inside a ternary.
On Reports, each call also rescans all search data, and nothing stops early when no report is deletable.
Extract a canDeleteAnyLoadedItem helper, and pass in the transactionsByReportID map the hook already builds if the scan matters on large accounts.
| await waitFor(() => { | ||
| expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.DELETE)).toBe(true); | ||
| }); |
There was a problem hiding this comment.
NAB: repeated test setup
The same waitFor, find and act block appears in all four tests that press Delete.
Extract a pressDelete(result) helper.
|
This is not specific to bulk delete flow but I noticed that when first 50 reports (first page) are NOT deletable and any deletable report exists in next page, bulk delete option doesn't show until next page is fetched. Not blocker though. Screen.Recording.2026-11-23.at.1.40.11.PM.mov |
|
Bug: unreported expenses are not deleted Screen.Recording.2026-11-23.at.1.48.15.PM.mov |
|
🎯 @jayeshmangwani, thanks for reviewing and testing this PR! 🎉 A payment issue will be created for your review once this PR is deployed to production. If payment is not needed (e.g., regression PR review fix etc), react with 👎 to this comment to prevent the payment issue from being created. |
|
@allgandalf tests failing |
| @@ -1751,7 +1776,12 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { | |||
| showConfirmModal, | |||
| deleteModalTitle, | |||
| deleteModalPrompt, | |||
There was a problem hiding this comment.
If I leave one loaded expense checked, the dialog asks me to delete “this expense” even though matches on later pages are still selected. Could we tell users that Delete applies to the whole selection, including results they haven’t loaded?
There was a problem hiding this comment.
done in 635b816, what do you think of the copy ?
|
@JS00001 tests are passing now, can you take another look ? |
|
Yep reviewing today |
|
🚧 luacmartins has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/luacmartins in version: 9.5.57-0 🚀
|
|
No help site update needed — this fixes Select all → Delete to delete all matching selected expenses and reports as users already expect, without adding a new workflow or making existing guidance incorrect. |
|
This PR failing in offline test because of the issue #108624 |
Explanation of Change
With Select all checked in Search, Delete goes to the backend like Hold does, so every matching report or expense is deleted, not just the loaded ones. Anything deselected is left out. Delete isn't offered under Select all when an expense is checked again inside a deselected group, since the bulk delete can't include it.
Fixed Issues
$ https://github.com/Expensify/Expensify/issues/688053
PROPOSAL:
Tests
Offline tests
QA Steps
Same as tests
PR Author Checklist
### 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