Skip to content

[Payment due @mananjadhav] Read attachment migration flag with Onyx.connectWithoutView - #100531

Merged
NicolasBonet merged 2 commits into
mainfrom
nicolas-attachment-migration-onyx-connect
Sep 8, 2026
Merged

NicolasBonet merged 2 commits into
mainfrom
nicolas-attachment-migration-onyx-connect

Conversation

@NicolasBonet

@NicolasBonet NicolasBonet commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Replaces the unsupported OnyxUtils.get() call with Onyx.connectWithoutView() when checking whether attachment paths have already been migrated. Follows the same Promise pattern as #99004 and #98714.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/643611
PROPOSAL: #96531 (comment)

Tests

Passed locally using the existing App dependency installation:

  • npm test -- --runInBand --watchman=false --runTestsByPath tests/unit/MoveFilesOutOfDocumentsTest.ts — all 11 tests passed, including first-run migration, record preservation, completed-migration skipping, and cleanup failure handling.
  • npm run typecheck — all five projects passed.
  • npm run lint-changed.
  • npm run spell-changed.
  • oxfmt --check src/libs/migrations/MoveFilesOutOfDocuments/index.native.ts.
  • git diff --check.

Native device testing has not been performed. Jest reported duplicate manual-mock warnings in unrelated modules; the suite passed.

Offline tests

Pending native verification:

  1. On a build predating Stop exposing app data to the iOS Files app #96531, cache chat attachments, then go offline.
  2. Upgrade to this build and verify the cached attachments still open.
  3. Kill and relaunch the app while offline and verify those attachments still open.

QA Steps

Pending on iOS and Android:

  1. With a build predating Stop exposing app data to the iOS Files app #96531 store some files in the Expensify folder in the Files app in iOS.
  2. Then upgrade to this build.
  3. Validate that your previously stored files are still there in the Files app.
  4. In a chat, download a PDF attachment. Verify the success message appears and the file shows up in the Files app folder.
  5. Download an image attachment. Verify it is saved to Photos, not the Files app folder.
  6. Download a video attachment. Verify it is saved to Photos and no temporary copy is left behind in the Files app folder.
  7. Export expenses as CSV: go to the Spend tab, long-press an expense (or use the ⋮ menu → Select multiple) and select a couple of expenses, then tap the "x selected" dropdown → Export → Basic export. Keep the selection small so the export downloads directly instead of being queued server-side. Verify the share sheet appears, "Save to Files" works, and no Expensify folder is left behind in the Files app folder.
  8. Download an attachment whose name is only digits (e.g. 2024.pdf). Relaunch the app and verify the file is still visible in the Files app folder (the OldDot migration must not sweep numeric-named user downloads).
  9. On a fresh install, verify startup succeeds when the flag and attachment collection are absent.
  10. Verify no errors appear in the JS console throughout.

PR Author Checklist

  • Linked the original issue and the follow-up review request.
  • Explained why the new Onyx.connectWithoutView() call is needed.
  • Ran the existing migration unit tests and code quality checks.
  • Added offline and native QA steps.
  • Ran the native QA and offline checks on iOS and Android.
  • Verified no JS console errors during native QA.

Screenshots/Videos

No UI changes. iOS native QA evidence below; Android still pending.

iOS QA test report (iPhone 17 simulator, HybridApp dev build)

All QA steps passed. The upgrade was emulated by seeding a fresh install with pre-#96531 files before first launch, which exercises the same code paths as a real upgrade.

  • ✅ Files stored before the upgrade are still in the Files app
  • ✅ Leftover internal files were cleaned up
  • ✅ PDF download: file appears in the Files app
  • ✅ Image download: saved to Photos
  • ✅ Video download: saved to Photos
  • ✅ CSV export: Share sheet appears
  • ✅ Digits-only download (2024.pdf): still visible in the Files app after relaunch
  • ✅ Fresh install: starts up fine with the flag and attachment collection absent
  • ✅ No JS console errors (only pre-existing dev-only warnings)
Files app after upgrade (user files kept) PDF download success alert
Files app after upgrade PDF Downloaded alert
CSV export Save to Files Files app after all downloads + relaunch
CSV Save to Files Files app final state

@NicolasBonet
NicolasBonet marked this pull request as ready for review September 8, 2026 14:31
@NicolasBonet
NicolasBonet requested review from a team as code owners September 8, 2026 14:31
@melvin-bot
melvin-bot Bot requested a review from mananjadhav September 8, 2026 14:31
@melvin-bot

melvin-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

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

@melvin-bot
melvin-bot Bot requested review from flaviadefaria and removed request for a team September 8, 2026 14:31
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

This PR adds a new Onyx.connectWithoutView call, so I've requested a review from the Onyx performance reviewers (@tgolen, @mountiny, @luacmartins) — a review from any one of them is enough. Please add a link in your PR description to the Slack discussion where the @frontend-performance team approved using connectWithoutView here.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-08T14:47:43.672700Z 0f9b8e9 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Thanks for refactoring this!

@NicolasBonet

Copy link
Copy Markdown
Contributor Author

@mananjadhav let's test this, upload the checklist and then we can merge, please 🙏

@mananjadhav

Copy link
Copy Markdown
Collaborator

Yes. Getting to checklist in next 30 mins.

@mananjadhav

Copy link
Copy Markdown
Collaborator

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-read-attach-migration.mov
Android: mWeb Chrome NA
iOS: HybridApp
ios-read-attach-migration.mov
iOS: mWeb Safari NA
MacOS: Chrome / Safari NA

@melvin-bot
melvin-bot Bot requested a review from Valforte September 8, 2026 18:19
@melvin-bot

melvin-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

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

@melvin-bot melvin-bot Bot changed the title Read attachment migration flag with Onyx.connectWithoutView [Payment due @mananjadhav] Read attachment migration flag with Onyx.connectWithoutView Sep 8, 2026
@melvin-bot

melvin-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

🎯 @mananjadhav, thanks for reviewing and testing this PR! 🎉

A payment issue will be created for your review once this PR is deployed to production.
E/E issue linked to the PR - https://www.github.com/Expensify/Expensify/issues/643611.

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.

@NicolasBonet
NicolasBonet merged commit cb99845 into main Sep 8, 2026
54 of 55 checks passed
@NicolasBonet
NicolasBonet deleted the nicolas-attachment-migration-onyx-connect branch September 8, 2026 18:47
@OSBotify

OSBotify commented Sep 8, 2026

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.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

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

@OSBotify OSBotify mentioned this pull request Sep 9, 2026
83 tasks done
@OSBotify

OSBotify commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/NicolasBonet in version: 9.4.75-0 🚀

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

@MelvinBot

MelvinBot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

🤖 No help site changes are required for this PR. I did not create a docs PR.

Why: the diff touches one file, src/libs/migrations/MoveFilesOutOfDocuments/index.native.ts, and only swaps how the migration reads its own persisted flag — OnyxUtils.get() becomes a Promise-wrapped Onyx.connectWithoutView(). The migration's outcome is unchanged: same files moved, same records updated, same flag written. Nothing a member, admin, or Guide sees or does changes.

How I checked the help site

I searched docs/articles for the topics this code could plausibly affect — attachments, attachment downloads, the iOS Files app, Photos/camera roll, and on-device storage.

The help site describes product behavior, not client-side storage internals. This change has no user-facing surface to document.

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

(Note: there is no linked help site PR — I found no docs change to make. If you believe a specific article should still be updated, reply with @MelvinBot and point me at it and I will open the draft PR.)


view run · view recording

@IuliiaHerets

Copy link
Copy Markdown

Hi @NicolasBonet. How can we execute Step 2 if we’re using the latest build? Should we download the lowest build first, complete the required steps, and then install the latest build to continue?

image

cc @tgolen @flaviadefaria @Valforte al

@NicolasBonet

Copy link
Copy Markdown
Contributor Author

Hi @NicolasBonet. How can we execute Step 2 if we’re using the latest build? Should we download the lowest build first, complete the required steps, and then install the latest build to continue?

  1. Fully uninstall the current version.
  2. Then install a previous version, some version of a couple of days ago should be fine, let me know if you cannot do this.
  3. Store some files in the Files App -> Expensify folder
  4. Then upgrade to this build.

Continue with steps 2 and so on from the QA steps.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.4.75-3 🚀

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

Bundle Size Analysis (Sentry):

@melvin-bot

melvin-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

🤖 Payment issue created: #100894

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.4.75-3 🚀

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

Bundle Size Analysis (Sentry):

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.

6 participants