Skip to content

feat: Wire ExportDownloadStatusModal into CSV export flow#92169

Merged
mollfpr merged 44 commits into
Expensify:mainfrom
truph01:fix/90298
Jun 17, 2026
Merged

feat: Wire ExportDownloadStatusModal into CSV export flow#92169
mollfpr merged 44 commits into
Expensify:mainfrom
truph01:fix/90298

Conversation

@truph01

@truph01 truph01 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

This change wires the new ExportDownloadStatusModal into the Search bulk-export (CSV/template) flow so users get in-app feedback on their export instead of relying solely on the "Concierge will send" confirmation.

Fixed Issues

$ #90298
PROPOSAL:

Tests

Test 1:

  1. Open ND.
  2. Navigate to Spend > Expenses.
  3. Select any expense.
  4. Click the "x selected" dropdown button, then choose Export > All Data - Expense Level.
  5. Verify that the following modal is displayed:
    Screenshot 2026-06-11 at 11 00 30
  6. Wait a few seconds until the following modal appears:
    Screenshot 2026-06-11 at 11 01 17
  7. Click Download file.
  8. Verify that the file downloads successfully.

Test 2:

  1. Open ND.
  2. Navigate to Spend > Expenses.
  3. Select any expense.
  4. Click the "x selected" dropdown button, then choose Export > All Data - Expense Level.
  5. Verify that the following modal is displayed:
    Screenshot 2026-06-11 at 11 00 30
  6. Click on "Send me the file when it's ready".
  7. Click on "Go to Concierge" button.
  8. Wait a few seconds until the download file is received.
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

Test 1:

  1. Open ND.
  2. Navigate to Spend > Expenses.
  3. Select any expense.
  4. Click the "x selected" dropdown button, then choose Export > All Data - Expense Level.
  5. Verify that the following modal is displayed:
    Screenshot 2026-06-11 at 11 00 30
  6. Wait a few seconds until the following modal appears:
    Screenshot 2026-06-11 at 11 01 17
  7. Click Download file.
  8. Verify that the file downloads successfully.

Test 2:

  1. Open ND.
  2. Navigate to Spend > Expenses.
  3. Select any expense.
  4. Click the "x selected" dropdown button, then choose Export > All Data - Expense Level.
  5. Verify that the following modal is displayed:
    Screenshot 2026-06-11 at 11 00 30
  6. Click on "Send me the file when it's ready".
  7. Click on "Go to Concierge" button.
  8. Wait a few seconds until the download file is received.
  • 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 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
    • 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
Android: mWeb Chrome
Screen.Recording.2026-06-15.at.09.51.15.mov
iOS: Native
iOS: mWeb Safari
Screen.Recording.2026-06-15.at.09.47.16.mov
MacOS: Chrome / Safari
Screen.Recording.2026-06-15.at.09.44.30.mov
Screen.Recording.2026-06-15.at.17.25.16.mov

@melvin-bot

melvin-bot Bot commented Jun 1, 2026

Copy link
Copy Markdown

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

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 ts-node ./scripts/generateTranslations.ts --help

Typically, you'd want to translate only what you changed by running npx ts-node ./scripts/generateTranslations.ts --compare-ref main

@truph01 truph01 changed the title feat: Wire ExportDownloadStatusModal into CSV export flow [WIP] feat: Wire ExportDownloadStatusModal into CSV export flow Jun 1, 2026
@truph01 truph01 marked this pull request as ready for review June 1, 2026 07:07
@truph01 truph01 requested review from a team as code owners June 1, 2026 07:07
@melvin-bot melvin-bot Bot requested review from daledah and heyjennahay and removed request for a team June 1, 2026 07:08
@melvin-bot

melvin-bot Bot commented Jun 1, 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]

@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: f1fd1abe69

ℹ️ 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/libs/actions/Search.ts Outdated
exportID,
}) as QueueExportSearchItemsToCSVParams;

API.write(WRITE_COMMANDS.QUEUE_EXPORT_SEARCH_ITEMS_TO_CSV, finalParameters, {optimisticData});

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 Add failure data for failed queued exports

When QueueExportSearchToCSV returns a non-200 response, SaveResponseInOnyx only applies the request's failureData; this request now writes an optimistic preparing export entry but provides no rollback. In that failure scenario the new CSV export modal remains stuck in the non-dismissible preparing state because the Onyx entry is never cleared or moved to failed (the same pattern appears in queueExportSearchWithTemplate below). Please include failure/finally data that clears or fails the export entry.

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.

Add failure data

@codecov

codecov Bot commented Jun 1, 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/libs/API/types.ts 100.00% <ø> (ø)
src/libs/actions/Search.ts 38.61% <100.00%> (+2.91%) ⬆️
src/components/ExportDownloadStatusModal.tsx 96.36% <94.11%> (+2.36%) ⬆️
src/components/Search/SearchBulkActionsButton.tsx 1.58% <0.00%> (-0.03%) ⬇️
src/hooks/useSearchBulkActions.ts 54.87% <36.84%> (+2.92%) ⬆️
... and 13 files with indirect coverage changes

@truph01

truph01 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

@MelvinBot With the current fileDownload in ExportDownloadStatusModal component, when the downloadURL is "https://staging.expensify.com/secure?secureType=csvexport&filename=csv_exports%2Fexport_2026-06-01_08-52-39_6a1d485737eba.csv&downloadName=export_2026-06-01_08-52-39_6a1d485737eba.csv",
it opens https://staging.expensify.com/secure?secureType=csvexport&filename=csv_exports%2Fexport_2026-06-01_08-52-39_6a1d485737eba.csv&downloadName=export_2026-06-01_08-52-39_6a1d485737eba.csv in new tab without downloading.

Please help investigate.

@MelvinBot

Copy link
Copy Markdown
Contributor

Issue Analysis

Root Cause: ExportDownloadStatusModal calls fileDownload(translate, downloadURL) with the raw secure URL and no encryptedAuthToken (ExportDownloadStatusModal.tsx:62 and :78). The /secure?secureType=csvexport&... endpoint requires authentication, but fetchFileDownload sends the request with credentials: 'same-origin' — and since NewDot and *.expensify.com are different origins, no cookies are sent and there's no token in the URL. The unauthenticated cross-origin fetch() fails, so the .catch() fallback runs Link.openExternalLink(url) → the URL opens in a new tab instead of downloading.

The URL itself is fine (tryResolveUrlFromApiRoot normalizes the staging.expensify.com origin, so isApiUrl is true and the early-return branch is not taken). The problem is purely the missing auth token on the request.

Recommended Fix: Mirror the existing secure-file download pattern — wrap the URL with addEncryptedAuthTokenToURL(...) before passing it to fileDownload, in both call sites:

import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL';
// ...
const [session] = useOnyx(ONYXKEYS.SESSION);
const encryptedAuthToken = session?.encryptedAuthToken ?? '';
// ...
fileDownload(translate, addEncryptedAuthTokenToURL(downloadURL, encryptedAuthToken, true));

hasOtherParameters must be true because downloadURL already has query params (it appends &encryptedAuthToken=...).

Investigation details & evidence

Why the fetch fails without the token. fetchFileDownload only opens a new tab in two places:

  1. The early-return at L47-L56 — not hit here: shouldOpenExternalLink is false (modal passes only 2 args), isAttachmentUrl is false (ATTACHMENT_LOCAL_URL_PREFIX is ['blob:', 'file:']), and isApiUrl is true because tryResolveUrlFromApiRoot rewrites the https://staging.expensify.com/ origin to the current API root, which the very next line then compares against.
  2. The .catch() at L78-L85 — this is the path taken. The actual request uses the original url with credentials: 'same-origin', so the cross-origin secure endpoint gets no auth → the fetch rejects → new tab.

Proven working pattern (same URL shape, same fetchFileDownload): WalletStatementPage.tsx:82 downloads a secure?secureType=pdfreport&... URL on the same host and it works — because it appends the token via addEncryptedAuthTokenToURL. Same approach in Report.downloadReportPDF and TravelInvoicingUtils.ts:151. The token is read from session.encryptedAuthToken (Session type).

(Note: the other CSV-export call sites — Search.ts, Domain.ts, Policy/*.ts — use a different mechanism: a POST to an /api/... command URL with the authToken in formData. That pattern doesn't apply here because your downloadURL is already a fully-formed secure?secureType=... file URL, so the PDF/secure pattern is the right match.)

Optional secondary nit: the modal passes no fileName (3rd arg). On the success path the blob would still download, but supplying a name (you have downloadName=... in the URL) gives a proper filename and lets the JSON-error guard at L67-L69 catch a server error response for .csv downloads.


Next Steps: Reply with @MelvinBot implement this to create a draft PR with the fix, or @MelvinBot <your feedback> to refine this analysis.

@daledah

daledah commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

@truph01 is this PR ready for review?

@trjExpensify

Copy link
Copy Markdown
Contributor

@truph01 bump on the question above.

@truph01

truph01 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

@truph01 is this PR ready for review?

@daledah No, i am still working on it. I will remove "WIP" label once it is ready for review.

@dannymcclain

Copy link
Copy Markdown
Contributor

didn't we land on wanting to open Concierge in the RHP when clicked here to keep people in the current context? I think that would be better.

Agree with that Tom, I think that'd be nice.

@mollfpr

mollfpr commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Yeahhh, I miss that part 😅

@truph01 I think we only need to update handleGoToConcierge, right?

@truph01

truph01 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

@truph01 I think we only need to update handleGoToConcierge, right?

@mollfpr I updated handleGoToConcierge. Here is result:

Screen.Recording.2026-06-17.at.10.19.19.mov

@mollfpr

mollfpr commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Love it! Thanks @truph01!

@mollfpr

mollfpr commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

@truph01 the changes looks good to me! Only need to fix the failing test.

@truph01

truph01 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

@mollfpr All good now

@mollfpr mollfpr merged commit 257cd2d into Expensify:main Jun 17, 2026
33 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.10-0 🚀

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

Bundle Size Analysis (Sentry):

@MelvinBot

Copy link
Copy Markdown
Contributor

Help site review — docs update required ✅

This PR changes how Search bulk exports (CSV/template) are delivered: instead of the old "Concierge will send the file" confirmation, users now see an in-app Preparing download window that downloads the file directly, with an option to Send me the file when it's ready via Concierge.

This makes the Export as CSV sections (Web + Mobile) and the How do I receive my export? FAQ in Search-and-Download-Expenses.md outdated, since they still describe Concierge as the only delivery method.

Draft help site PR: #93866

What changed in the docs
  • Export as CSV → Web / Mobile: replaced the "You'll receive a message from Concierge" line with the in-app download status modal behavior.
  • FAQ → How do I receive my export?: replaced the Basic-vs-other-templates Concierge split with the unified status-modal flow.

UI copy (Send me the file when it's ready, Preparing download) was sourced from the merged exportDownload strings in src/languages/en.ts. Navigation labels were left unchanged as they already match the 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.

@nlemma

nlemma commented Jun 17, 2026

Copy link
Copy Markdown

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

@nlemma

nlemma commented Jun 17, 2026

Copy link
Copy Markdown

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

@OSBotify

Copy link
Copy Markdown
Contributor

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

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

Bundle Size Analysis (Sentry):

@MelvinBot

Copy link
Copy Markdown
Contributor

Help site changes required ✅

This PR changes a user-facing flow: CSV/template exports from Spend no longer always arrive as a Concierge direct message. Instead, the new ExportDownloadStatusModal shows an in-app status window while the file is prepared, then downloads the file directly in the app (with the option to have Concierge send it via Send me the file when it's ready).

The existing help article Search-and-Download-Expenses.md still told users they'd "receive a message from Concierge with the exported file," which is now outdated.

Draft help site PR: #93890

It updates the Export as CSV (Web), Export as CSV (Mobile), and FAQ → How do I receive my export? sections to describe the status-window + in-app download behavior. UI labels were verified against the exportDownload strings in src/languages/en.ts.

@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.

@OSBotify

Copy link
Copy Markdown
Contributor

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

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

Bundle Size Analysis (Sentry):

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/puneetlath in version: 9.4.14-1 🚀

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants