Skip to content

Save offline receipts on sign out - #97562

Merged
mountiny merged 9 commits into
Expensify:mainfrom
callstack-internal:Save-offline-receipts-on-sign-out
Aug 7, 2026
Merged

mountiny merged 9 commits into
Expensify:mainfrom
callstack-internal:Save-offline-receipts-on-sign-out

Conversation

@rinej

@rinej rinej commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

On iOS and Android, if you sign out while a receipt is still uploading, the app now saves that receipt image to your device gallery before it clears storage. That way you can add it again later instead of losing it.

Manual sign-out from Settings shows a short confirmation prompt. Forced sign-outs (expired or invalid session) save silently without a prompt. If saving fails for any reason, sign-out still completes normally.

It is based on the reverted PR -> #94973
Just added the fix for the regression -> #95957

Fixed Issues

$ #97487
PROPOSAL: #92139 (comment)

Tests

Test 1 denied permission shows the modal

Precondition: iOS Settings → Expensify → Photos → None

  1. Launch the app and open a workspace chat.
  2. Turn on airplane mode / go offline.
  3. Create a scan expense with an image receipt so it stays queued (uploading).
  4. Go back to the LHN → Account → Sign out → tap Save and sign out.
  5. ✅ Verify the storage-access modal appears (title/message about photo access, with Cancel / Settings buttons), and sign-out still completes to the sign-in screen.

Test 2 - Happy path: receipt is saved

Precondition: iOS Settings → Expensify → Photos → Add Photos Only (or All Photos)

  1. Go offline, create a scan expense with an image receipt (stays queued).

  2. Sign out → confirm.

  3. ✅ Verify no permission modal appears, sign-out completes, and the receipt image is now in the Camera Roll / Photos.

  4. Repeat for other platforms

Offline tests

QA Steps

  • Same as Tests

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 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 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)
  • 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.
  • 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.

Permission Already Granted:

NotificationWithSettingGranted.mp4

Permission First Granted:

NotificationFixWithNoPermissions.mp4

Permission Already Denied:

NotificaitonWithNoPermissionGranted.mp4

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@melvin-bot

melvin-bot Bot commented Jul 31, 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

@codecov

codecov Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

@rinej
rinej marked this pull request as ready for review July 31, 2026 11:25
@rinej
rinej requested review from a team as code owners July 31, 2026 11:25
@melvin-bot
melvin-bot Bot requested review from eVoloshchak and removed request for a team July 31, 2026 11:25
@melvin-bot

melvin-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

@eVoloshchak 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: 97fc48e243

ℹ️ 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 on lines +7 to +8
const sourcePath = localPath.startsWith('file://') ? decodeURI(localPath) : localPath;
return RNFetchBlob.MediaCollection.copyToMediaStore(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Strip file:// before Android gallery saves

When the pending receipt path is the durable native URI returned by moveReceiptToDurableStorage (for example file:///.../Receipts-Upload/foo.jpg), this helper only decodes the URI and still passes the file:// scheme into RNFetchBlob.MediaCollection.copyToMediaStore. The Android download path already notes that copyToMediaStore takes a bare POSIX path, and the previous implementation passed fileURIToPath(url) for local files; with the new helper, saving offline receipts on Android will fail for the common file:// receipt paths right before sign-out clears the queue.

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.

added the change, now we use fileURIToPath in android save to browser logic

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

Big fan on this one. LGTM

@eVoloshchak

eVoloshchak commented Aug 4, 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
screen-20260804-162022-1785853180379.mp4
iOS: HybridApp
Screen.Recording.2026-08-04.at.15.56.17.mov
Screen.Recording.2026-08-04.at.15.51.14.mov
Screen.Recording.2026-08-04.at.15.48.22.mov

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

LGTM!
TS check failing does not seem related to this PR

@melvin-bot
melvin-bot Bot requested a review from mountiny August 4, 2026 14:28
@eVoloshchak

Copy link
Copy Markdown
Contributor

Test 1 denied permission shows the modal
Precondition: iOS Settings → Expensify → Photos → None

  1. Launch the app and open a workspace chat.
  2. Turn on airplane mode / go offline.
  3. Create a scan expense with an image receipt so it stays queued (uploading).
  4. Go back to the LHN → Account → Sign out → tap Save and sign out.
  5. ✅ Verify the storage-access modal appears (title/message about photo access, with Cancel / Settings buttons), and sign-out still completes to the sign-in screen.

This isn't ideal, since you see the message about Expensify not being able to save your image after you've already clicked "Sign Out", so even if you click the Settings button and grant the permission, the image is lost forever.
But I don't see an elegant way around it, and this is a scenario where the user specifically rejected the permission, so this won't be confusing, I think

@rinej

rinej commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor Author

thanks for review! The typecheck is gone now 👍

Test 1 denied permission shows the modal
Precondition: iOS Settings → Expensify → Photos → None

I agree, and it's unavoidable on iOS, we only learn access is None when the write itself rejects, by which point the user has already confirmed sign-out. It only happens on an explicit denial and the receipt loss is covered by the general offline-data-loss warning, I think this is acceptable

@mountiny

mountiny commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

The gh actions are down now

@rinej

rinej commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Only Verify peer review fails now

@mountiny mountiny closed this Aug 7, 2026
@mountiny mountiny reopened this Aug 7, 2026

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

2nd attempt

@mountiny
mountiny merged commit a0a0ab5 into Expensify:main Aug 7, 2026
43 of 45 checks passed
@OSBotify

OSBotify commented Aug 7, 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 Aug 7, 2026

Copy link
Copy Markdown
Contributor

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

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.4.52-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

Help site review — no docs changes required ✅

I reviewed the changes in this PR against App/docs/articles and no help site update is needed.

Why: This PR re-lands the "save offline receipts on sign out" feature (from the reverted #94973) plus the regression fix, and its primary customer-facing behavior is already documented in the New Expensify help site:

What happens to receipts that are still uploading when I sign out on mobile?
If you manually sign out of the Expensify mobile app while receipts are still uploading, Expensify prompts you to save the pending receipt images to your device's photos before signing out.

That article accurately reflects the manual sign-out flow this PR ships (the confirmation prompt → Save and sign out → receipts saved to the device's Photos). Since the behavior matches what's already published, there's nothing to add, so I did not open a draft PR.

Edge cases I considered but left undocumented

The PR also handles two behaviors that aren't in the article, but neither is worth surfacing to end users:

  • Forced sign-outs (expired/invalid session, SAML re-auth) save the receipts silently with no prompt. "Forced sign-out" isn't a user-initiated action, so it's not actionable help-site content.
  • If saving fails (e.g., the OS denies gallery access), sign-out still completes normally. This is graceful-degradation an end user wouldn't look up.

If you'd like, I'm happy to extend the existing Q&A to mention the "even if a session expires, we still try to save your receipts" behavior — just let me know and I'll draft it.

Note: this is a mobile-native-only feature (iOS/Android), so it isn't reproducible on the web build.


@rinej, since the behavior is already covered by the existing Create-an-Expense help article, please confirm it still reflects the current behavior. If you'd rather I add the forced-sign-out/failure nuance, reply and I'll open a draft help site PR.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/roryabraham in version: 9.4.52-11 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 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.

7 participants