Skip to content

[Download receipts] Add "Download receipts" to the Expenses and Reports search pages - #97671

Merged
mollfpr merged 16 commits into
Expensify:mainfrom
truph01:feat/95355
Aug 17, 2026
Merged

[Download receipts] Add "Download receipts" to the Expenses and Reports search pages#97671
mollfpr merged 16 commits into
Expensify:mainfrom
truph01:feat/95355

Conversation

@truph01

@truph01 truph01 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Fixed Issues

$ #95355
PROPOSAL:

Tests

  1. Request two expenses with receipts to workspace.
  2. Go to Spend > Expenses > Choose 2 expenses in step 1
  3. Click on "2 Selected" dropdown button and choose "Download receipts"
  4. Verify you can go to the download flow and can download the receipt successfully
  5. Go to Spend > Reports > Choose report in step 1
  6. Click on "1 Selected" dropdown button and choose "Download receipts"
  7. Verify you can go to the download flow and can download the receipt successfully
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

// TODO: These must be filled out, or the issue title must include ""[No QA].""
Same as tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained ""why"" the code was doing something instead of only explaining ""what"" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named ""index.js"". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Screen.Recording.2026-08-11.at.18.41.23.mov
Android: mWeb Chrome
Screen.Recording.2026-08-11.at.18.38.21.mov
iOS: Native
Screen.Recording.2026-08-11.at.18.38.55.mov
iOS: mWeb Safari
Screen.Recording.2026-08-11.at.18.27.26.mov
MacOS: Chrome / Safari
Screen.Recording.2026-08-11.at.18.26.07.mov

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

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.

Files with missing lines Coverage Δ
src/CONST/index.ts 94.85% <ø> (ø)
src/hooks/useSearchBulkActions.ts 60.78% <100.00%> (+0.69%) ⬆️
src/hooks/useExportActions.ts 60.91% <0.00%> (ø)
src/libs/actions/Export.ts 77.50% <0.00%> (-4.08%) ⬇️
... and 6 files with indirect coverage changes

@truph01
truph01 marked this pull request as ready for review August 3, 2026 10:04
@truph01
truph01 requested review from a team as code owners August 3, 2026 10:04
@melvin-bot
melvin-bot Bot requested review from daledah and heyjennahay and removed request for a team August 3, 2026 10:04
@melvin-bot

melvin-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

@daledah 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]

@truph01

truph01 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

I will update the videos in checklist once it is good to merge

Comment thread src/hooks/useSearchBulkActions.ts Outdated
}

const isExpenseSearch = queryJSON?.type === CONST.SEARCH.DATA_TYPES.EXPENSE || searchResults?.search.type === CONST.SEARCH.DATA_TYPES.EXPENSE;
if (isExpenseSearch && selectedTransactionsKeys.length > 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ CONSISTENCY-3 (docs)

This new options.push({...}) block for the "Download receipts" action is a near-verbatim copy of the block added directly above it for isExpenseReportSearch. Both push an option with the same icon, text, value, shouldCloseModalOnSelect, and an identical onSelected handler (offline guard + exportReceiptsToZip(...) + trackExport(exportID)). The only differences are the guard condition and the single argument passed to exportReceiptsToZip ({reportIDs} vs {transactionIDs}). Duplicating the whole option object increases maintenance overhead — any future change to the action (icon, copy, offline behavior) has to be made in two places.

Consolidate into a single block that computes the argument once, e.g.:

const receiptExportArgs = isExpenseReportSearch && selectedReportIDs.length > 0
    ? {reportIDs: selectedReportIDs}
    : isExpenseSearch && selectedTransactionsKeys.length > 0
        ? {transactionIDs: selectedTransactionsKeys}
        : undefined;

if (receiptExportArgs) {
    options.push({
        icon: expensifyIcons.Download,
        text: translate('common.downloadReceipts'),
        value: CONST.SEARCH.BULK_ACTION_TYPES.DOWNLOAD_RECEIPTS,
        shouldCloseModalOnSelect: true,
        onSelected: () => {
            if (isOffline) {
                setIsOfflineModalVisible(true);
                return;
            }
            const exportID = exportReceiptsToZip(receiptExportArgs);
            trackExport(exportID);
        },
    });
}

Reviewed at: a1fd2d8 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a1fd2d81dd

ℹ️ 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".

Comment thread src/hooks/useSearchBulkActions.ts Outdated
setIsOfflineModalVisible(true);
return;
}
const exportID = exportReceiptsToZip({transactionIDs: selectedTransactionsKeys});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Don't send grouped selection keys as receipt transaction IDs

On a grouped Expenses search, selecting a group before its children are fetched stores the selection under the group_... key (the CSV export path already detects this and avoids passing those keys as transaction IDs). This new action passes selectedTransactionsKeys directly to ExportReceiptsToZip, so in that grouped-selection state the request sends a group key instead of real transaction IDs and the receipts export fails or misses the selected group's receipts. Filter/expand grouped selections or disable this action for group-key selections.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved via 5a8472d

Comment thread src/hooks/useSearchBulkActions.ts Outdated
// transaction ID. Drop those keys so ExportReceiptsToZip only receives valid transaction IDs.
const transactionIDs = selectedTransactionsKeys.filter((key) => !key.startsWith(CONST.SEARCH.GROUP_PREFIX));
if (transactionIDs.length === 0) {
return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With shouldCloseModalOnSelect: true, the bare return means the menu just closes and nothing happens - no modal, no error, no console warning.

So i think we can call setIsDownloadErrorModalVisible(true); here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved via 184b81a

@daledah

daledah commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@truph01 could you please add unit tests to cover the logic changed in this PR?

@daledah

daledah commented Aug 3, 2026

Copy link
Copy Markdown
Contributor
Screen.Recording.2026-08-04.at.00.55.18.mov

@mollfpr @truph01 should we show the Download receipts option for reports that don't have any expenses?

@daledah

This comment was marked as duplicate.

@mollfpr
mollfpr self-requested a review August 4, 2026 16:03
@mollfpr

mollfpr commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@daledah Good catch! I think we don't need to show the option for no expense report.

@truph01

truph01 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

fix: dont show the option for no expense report

Resolved via a8df631

@truph01

truph01 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@truph01 could you please add unit tests to cover the logic changed in this PR?

I've added test via 3c16fee

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🚧 mollfpr has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

This comment has been minimized.

@daledah

daledah commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

We're still waiting to fix the bug mentioned in this comment

@truph01

truph01 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

We're still waiting to fix the bug mentioned in this comment

@daledah It works well now.

@daledah

daledah commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
android.mov
Android: mWeb Chrome
andorid-mweb.mov
iOS: HybridApp
i.mov
iOS: mWeb Safari
im.mov
MacOS: Chrome / Safari
Screen.Recording.2026-08-13.at.14.15.40.mov

@quinthar quinthar removed the #convert label Aug 13, 2026
@daledah

daledah commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

@truph01 please merge main to fix the failing check

@daledah daledah left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the changes LGTM

@mollfpr
mollfpr merged commit 2cc56d9 into Expensify:main Aug 17, 2026
36 of 38 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 mollfpr has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mollfpr in version: 9.4.55-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

Yes — help site changes are required, and I've drafted them.

This PR adds a Download receipts bulk action to the multi-select menu on the Spend > Expenses and Spend > Reports search pages. The most relevant help article — Export Expenses and Reports — documents that same bulk-action menu (including Download as PDF) but didn't mention receipt downloads, so it was out of date.

Draft help site PR: #98819

What it updates in Search-and-Download-Expenses.md:

  • New Download receipts section with steps for both the Reports and Expenses pages
  • Added it to the Export Options list
  • Two new FAQ entries ("Can I download receipts in bulk?" and "Why do I see 'No receipts to download'?")
  • Added download receipts / receipts ZIP keywords to the metadata

The Download receipts label is taken verbatim from the merged translation string (common.downloadReceipts), and the navigation labels were checked against the current New Expensify UI.

@truph01, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review

@jponikarchuk

Copy link
Copy Markdown

Deploy Blocker #98827 was identified to be related to this PR.

@jponikarchuk

Copy link
Copy Markdown

Deploy Blocker #98833 was identified to be related to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants