[Due for payment 2026-11-25] [$250] When sharing multiple files to create expenses in New Dot, the image preview shown is incorrect.
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: 9.4.25-1 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from BrowserStack: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: @danieldoglas Slack conversation (hyperlinked to channel name): #Expensify Bugs
Action Performed:
Pre-requisites: Be part of a workspace and have a workspace chat
- Go to your gallery, select a receipt and take a screenshot or Navigate to any page in phone and take a screensot
- Open the native share modal (from the iOS screenshot manager)
- Select expensify
- Select your workspace chat.
- Check the preview image, and it shows the receipt you just selected.
- Save that receipt.
- Go back to your gallery, select a different receipt and take a screenshot or Navigate to any page in phone and take a screensot
- do steps (2), (3), (4) again
Expected Result:
The receipt you see in the preview image is the one you last selected
Actual Result:
The receipt you see is the previous one you selected. If you add 10 separate receipts using this flow, it will always show the first receipt in the preview.
Workaround:
Unknown
Platforms:
Select the officially supported platforms where the issue was reproduced:
- [ ] Android: App
- [ ] Android: mWeb Chrome
- [x] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [ ] Windows: Chrome
- [ ] MacOS: Chrome / Safari
Screenshots/Videos
https://github.com/user-attachments/assets/98d56d8d-ad3c-4da4-9675-ae23e5f4723b
https://github.com/user-attachments/assets/164e54aa-f169-4b20-b4b6-d398e244c103
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022072372886498778552
- Upwork Job ID: 2072372886498778552
- Last Price Increase: 2026-07-22
Issue Owner
Current Issue Owner: @mallenexpensify
Proposal
What is the root cause of that problem?
When you share a screenshot/image to Expensify via the iOS Share Extension, the image arrives as a UIImage and is written to the app group with a hardcoded filename, shared_image.png:
ios/ShareViewController/ShareViewController.swift:193-197—handleImageDataalways saves as"shared_image.png".
The native module then hands the JS side the file URI derived from that path:
ios/RCTShareActionHandlerModule.m:89—content = [fileURL absoluteString], i.e.file:///…/sharedFiles/shared_image.png.
Because the filename never changes, this content URI is byte-for-byte identical on every share. The receipt preview is rendered from that URI:
SubmitDetailsPage.tsx:156→SubmitDetailsPage.tsx:450—receiptPath={currentReceiptSource}= the shared file URI.
The image layer (RN <Image> / native image + NSURLCache) keys its cache on the URI. The extension overwrites the file on disk each time (setupSharedFolder clears the folder), but the cache still serves the first decoded image because the URI is unchanged. That is why every subsequent share previews the first receipt you shared.
Note: the id field returned by the module is unique (timestamp-based, RCTShareActionHandlerModule.m:123-127), but the preview keys off content (the path), not id — so the uniqueness never reaches the image cache.
Why it only reproduces with screenshots / gallery images
Files shared as real file URLs (e.g. a PDF or a Files-app document) flow through handleURLData, which keeps the original lastPathComponent — those tend to have varying names, so the cache-collision doesn't happen. Screenshots and gallery images come in as UIImage, hitting the hardcoded shared_image.png path, which is exactly the flow in the repro steps. This matches the reported "iOS: App only" platform.
What changes do you think we should make in order to solve the problem?
Give each shared image a unique filename so every share produces a distinct URI and defeats the cache collision. In handleImageData (ShareViewController.swift:193), replace the constant "shared_image.png" with a name that includes a unique token (e.g. a timestamp or UUID), such as shared_image_<uuid>.png. Since setupSharedFolder already clears the folder before each save, unique names won't accumulate.
This is the smallest, most robust fix because it removes the identical-URI condition at the source rather than fighting the cache downstream.
What alternative solutions did you explore? (Optional)
- Cache-bust on the JS side: append a unique query/token to
currentReceiptSourcebefore passing it to the preview (e.g. use the already-uniqueid, or?t=<processedAt>). Works, but treats the symptom and every consumer ofcontentmust remember to do it. - Force-uncache the image: clear the RN/native image cache for the URI on each share — brittle and platform-specific.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/95075) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On iOS, when a user shares a receipt to Expensify via the native share sheet a second time (after having shared one previously in the same app session), the Share preview screen displays the previously shared receipt image instead of the newly selected one. Expected: the preview should show the receipt the user just selected in the share sheet.
What is the root cause of that problem?
On the initial mount of ShareRootPage, clearShareData() is called before handleProcessFiles() (src/pages/Share/ShareRootPage.tsx:152-156), which nulls out ONYXKEYS.SHARE_TEMP_FILE. However, when the app is re-entered from a subsequent share (iOS keeps the process alive), the AppState background → active listener (src/pages/Share/ShareRootPage.tsx:138-150) calls handleProcessFiles() WITHOUT first calling clearShareData(). handleProcessFiles then uses addTempShareFile() which does Onyx.merge(ONYXKEYS.SHARE_TEMP_FILE, file) (src/libs/actions/Share.ts:23-25). Because Onyx.merge merges into the existing (previously-shared) file object and the Onyx cache/useOnyx selector still holds the prior currentAttachment, the preview keeps rendering the stale receipt from the first share.
What changes do you think we should make in order to solve the problem?
src/pages/Share/ShareRootPage.tsx:138-150— In theAppStatelistener, callclearShareData()beforehandleProcessFiles()on thebackground|inactive → activetransition, mirroring the initial-mount sequence at lines 152-156, so the previous share's Onyx state is discarded before the new file is written.src/pages/Share/ShareRootPage.tsx:83-136— Also reset localisFileReady/isFileScannable/errorTitle/errorMessageat the start ofhandleProcessFiles(or in the same re-entry path) so the tab navigator remounts against the fresh file rather than keeping the previous file's rendered state.src/libs/actions/Share.ts:23-25— SwitchaddTempShareFilefromOnyx.mergetoOnyx.setso a new file object fully replaces the previous one rather than being deep-merged onto stale keys (defense-in-depth against partial-field carry-over such as a cachedcontentURI).
What alternative solutions did you explore? (Optional)
Proposal
What is the root cause of that problem?
Screenshots/photos shared into the app arrive at the share extension as an in‑memory UIImage (the public.image representation), so they go through handleImageData, which always writes them to a constant filename shared_image.png:
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/ios/ShareViewController/ShareViewController.swift#L193-L197
The native module then turns that path into the file's content (fileURL absoluteString):
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/ios/RCTShareActionHandlerModule.m#L86-L90
So every image share produces the identical content URI file://…/sharedFiles/shared_image.png. The preview renders that exact URI as the receipt source:
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/src/pages/Share/SubmitDetailsPage.tsx#L156-L169
Causal chain: constant filename → identical content URI on every share → the app's image cache is keyed by URI, so it returns the first bitmap it ever loaded for that URI and ignores the freshly‑overwritten file → the preview always shows the first receipt. (The id/processedAt fields do get a timestamp, but they don't affect the displayed image source.)
What changes do you think we should make in order to solve the problem?
Give each shared image a unique filename in handleImageData instead of the constant shared_image.png — e.g. append a timestamp or UUID().uuidString to the name:
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/ios/ShareViewController/ShareViewController.swift#L193-L197
That makes each share's content URI distinct, so the image cache loads the new image every time. setupSharedFolder already clears the folder on each run, so this doesn't leak files.
What alternative solutions did you explore? (Optional)
Fix it on the JS side by cache‑busting the preview: append the already‑unique id/processedAt as a query suffix to currentReceiptSource (and the upload source) so the URI differs per share. This avoids native changes but treats the symptom rather than the constant‑filename root cause, and must be applied consistently to both the displayed and uploaded source.
🚨 Edited by proposal-police: This proposal was edited at 2026-07-01 17:34:14 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On iOS, when you share receipts to New Dot one after another (screenshot → native share → Expensify), the attachment preview keeps showing the first receipt you ever shared instead of the one you just picked. Every subsequent share shows the stale image.
What is the root cause of that problem?
The preview is cached against a file path that never changes between shares.
- The iOS share extension saves an incoming image to a hard-coded filename
shared_image.pnginside the app-group folder: https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/ios/ShareViewController/ShareViewController.swift#L193-L197 - On each new share,
setupSharedFolderwipes that folder and re-writes the file, so the bytes on disk are the new receipt but the path is byte-for-byte identical (…/sharedFiles/shared_image.png) every time: https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/ios/ShareViewController/ShareViewController.swift#L68-L87 - The native reader turns that path into
content = [fileURL absoluteString]and hands it to JS unchanged: https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/ios/RCTShareActionHandlerModule.m#L83-L101 - Both share screens read
contentand pass it straight to<Image source={{uri: source}}>, which caches the decoded image by URI:AttachmentPreview(share-to-chat): https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/src/pages/Share/ShareDetailsPage.tsx#L80 → https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/src/components/AttachmentPreview.tsx#L103-L104MoneyRequestConfirmationListreceipt (create-expense / Submit tab): https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/src/pages/Share/SubmitDetailsPage.tsx#L156
Because the URI string is a constant, Image returns the already-decoded first image and never reloads the new file. That is exactly the reported behavior: the 2nd share shows the previous one, and after N shares it always shows the very first receipt.
Why iOS-only: the same code on Android derives the filename from the content-provider DISPLAY_NAME, which is unique per file, so the URI changes every share and the cache never collides:
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/android/app/src/main/java/com/expensify/chat/utils/FileUtils.kt
What changes do you think we should make in order to solve the problem?
Make the saved image path unique per share so every consumer's URI differs. In handleImageData give the file a unique name:
let filename = "shared_image_\(UUID().uuidString).png"
That single change is the convergence point — content (native reader), the preview source, the seeded draft receipt.source, and the upload path all derive from this one filename, so fixing it here busts the cache everywhere at once with no JS change. (For robustness the same uniquification can be applied to the generic processAndSave path so any file type that reuses a name is covered.)
Regression safety: text shares are unaffected — they still write text_to_read.txt and are detected by the native containsString:@"text_to_read" check; only the image filename gains a unique suffix, and getFileName(content) downstream reads whatever name is present.
Why the obvious one-line fix does NOT work: the tempting fix is to add key={source} (or a ?t= cache-buster) to the AttachmentPreview in ShareDetailsPage. It can't work: source is the same string every share, so key never changes → the component never remounts. And even a working cache-buster there would miss the create-expense flow named in the title, whose preview comes from MoneyRequestConfirmationList receiptPath in SubmitDetailsPage reading the same cached URI. Worse, that URI is also fed to readFileAsync/setMoneyRequestReceipt for the actual upload, so appending a query/fragment to the file:// path risks breaking the file read. The cache is keyed on the URI itself — the only safe, complete fix is to make the URI unique at the source.
What alternative solutions did you explore? (Optional)
- JS cache-bust on the preview only — append
#${processedAt}tosourcein bothShareDetailsPageandSubmitDetailsPage. Incomplete and risky: you must patch every display sink separately (miss one and it stays stale), and you must carefully keep the fragment out of the upload/readFileAsyncpath that reads the samecontent. The native fix removes the dependency entirely instead of masking it per-render. - Clear the RN image cache on Share mount — global and heavy-handed; evicts unrelated cached images and only hides the symptom.
- Delete the file in the native reader after reading — no effect: the folder is already wiped each share by
setupSharedFolder; the URI is still identical.
Proposal
What is the root cause of that problem?
The share flow stores the incoming file in Onyx under SHARE_TEMP_FILE, where content is the on-disk path to the copied file (ShareTempFile.content is documented as "Path to the file copy in the app folder"). The preview screen renders an Image whose source is that content path.
Two things in the code I can see make the preview deterministically stale ("always the first receipt"):
-
addTempShareFilewrites withOnyx.mergeinstead ofOnyx.set: https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/src/libs/actions/Share.ts#L23-L25mergeis a partial deep update. If the native share extension copies each shared image to the same fixed path in the app group container (a very common pattern for share extensions), thencontentis byte-for-byte identical on every share. Merging an object whosecontentequals the stored value produces no change to that key, so the subscribed preview never re-renders with the new file. -
Even when the value does change,
<Image>caches by URI. Since the URI (contentpath) is reused across shares, React Native serves the cached bitmap from the very first shared file. That is exactly the reported symptom — the first receipt shows every time, for all 10 files.
clearShareData nulls the key with multiSet at the start of the flow, but nulling then re-writing the same file path still lands on the same cached URI, so it doesn't help the preview.
I want to be upfront: the native iOS share-extension copy code and the preview component weren't in the files I was given, so I can't permalink the exact line that writes the fixed filename or the Image source. The confirmable JS defect is the Onyx.merge on line 24; the "always first" behavior is the signature of a reused file path + URI-based image cache.
What changes do you think we should make in order to solve the problem?
Data/action layer plus render layer:
- Change
addTempShareFileinsrc/libs/actions/Share.tsfromOnyx.mergetoOnyx.setso a new share fully replaces the previousShareTempFileobject and doesn't inherit stale fields (e.g.aspectRatio) from the prior file. - Make the copied file path unique per share. The native share handler should write each shared file to a distinct name (include the generated
idor a timestamp), socontentchanges on every share.ShareTempFile.idalready exists for this — thread it into the copy filename. - On the preview
Image, bust the URI cache using the uniqueid— e.g. append?v=${id}to the source URI (or pass akey={id}). This guarantees a fresh decode even if a path is ever reused, and covers the offline/local-file case where the OS cache is the only thing serving the old bitmap.
Unique-path + Onyx.set fixes the data staleness; cache-busting fixes the Image staleness. Both are needed because either one alone can reproduce "always first."
What alternative solutions did you explore? (Optional)
Only changing Onyx.merge → Onyx.set without touching the file path or the image cache. Rejected: if the native extension keeps copying to the same path, set still stores an identical content string and the Image cache still serves the first bitmap, so the preview stays wrong. The unique-path/cache-bust piece is the part that actually breaks the "always first" behavior.
🚨 Edited by proposal-police: This proposal was edited at 2026-07-01 17:50:20 UTC.
Proposal
What is the root cause of that problem?
For image data received by the iOS share extension, we always save the shared image as shared_image.png inside the app-group sharedFiles folder. The folder is cleared for each share, but the next screenshot is written back to the same absolute file path, so JS receives the same file://.../sharedFiles/shared_image.png URI for every screenshot share.
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/ios/ShareViewController/ShareViewController.swift#L68-L87
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/ios/ShareViewController/ShareViewController.swift#L193-L197
The native bridge then exposes that file URL as the shared file content, and the submit details page stores that URI as the draft receipt source used by the confirmation preview.
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/ios/RCTShareActionHandlerModule.m#L64-L100
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/src/pages/Share/SubmitDetailsPage.tsx#L156-L175
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/src/pages/Share/SubmitDetailsPage.tsx#L439-L456
The receipt thumbnail path is cached by local source URI and the preview keeps the first local source unless the resolved URI changes. Because the file contents change but the file: URI does not, the first shared receipt remains the preview image for later shares.
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/src/components/MoneyRequestConfirmationListFooter/hooks/useReceiptThumbnailSource.ts#L32-L48
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/src/hooks/useLocalReceiptThumbnail.ts#L5-L17
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/src/hooks/useLocalReceiptThumbnail.ts#L50-L56
This is not solved just by clearing the optimistic transaction draft, because the submit participant selector already clears that draft before opening the submit details page.
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/src/components/Share/ShareTabParticipantsSelector.tsx#L26-L29
What changes do you think we should make in order to solve the problem?
Make the iOS share extension write each copied non-text shared file to a unique filename before opening the main app. For the UIImage path, replace the hardcoded shared_image.png name with a name that preserves the .png extension and includes a UUID or timestamp, such as shared_image_<uuid>.png.
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/ios/ShareViewController/ShareViewController.swift#L193-L197
I would also use the same unique-filename helper for URL/file-backed attachments before calling processAndSave, so two separate shares with the same original filename still produce different app-group paths. The existing folder cleanup can stay as-is, so this will not accumulate old shared files.
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/ios/ShareViewController/ShareViewController.swift#L68-L87
No JS cache-busting query string is needed. Once the native copy has a unique path, the bridge returns a new content URI, SubmitDetailsPage seeds that URI into the receipt draft, and the local receipt thumbnail/native image cache sees a new key for every share.
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/ios/RCTShareActionHandlerModule.m#L92-L100
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/src/libs/actions/IOU/Receipt.ts#L304-L318
Test coverage:
- Add a focused test for the filename helper, or the closest native test available, verifying two image shares produce different filenames while preserving the image extension.
- Manually verify on iOS by sharing receipt A through the native share sheet to a workspace chat, saving it, then sharing receipt B through the same flow and confirming the preview and saved expense both use receipt B.
- Repeat the manual check with at least three screenshots to confirm the preview does not keep the first receipt.
What alternative solutions did you explore? (Optional)
I considered clearing TRANSACTION_DRAFT${CONST.IOU.OPTIMISTIC_TRANSACTION_ID} and VALIDATED_FILE_OBJECT at the start of the share flow. That is useful cleanup, but it does not address the core stale-image case because the selected submit destination already clears the optimistic draft, while the preview can still receive the same local file URI.
I also considered appending a cache-busting query string in JS, but the upload path reads the same value as a real local file path. Changing the native copied filename is safer because it gives the preview and the upload code a real, unique file URI.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user shares a screenshot (receipt) from the iOS Photos app to Expensify via the native share sheet, the image preview shown in the New Dot Share flow is stale. Instead of showing the receipt that was just selected, it shows a receipt from a previous share session. If the user repeats this flow for 10 different receipts, the preview always shows the very first receipt that was ever shared.
What is the root cause of that problem?
The iOS Share Extension writes shared image data to the app group container using a hard-coded, constant filename (shared_image.png) instead of a unique name per share. Every screenshot shared through the native share sheet (which arrives as raw UIImage data rather than a public.file-url) is written to the exact same path on disk.
This is the extension entry point that saves image attachments under that fixed name: https://github.com/Expensify/App/blob/252374e047412ba7c271e162264f0bc283fa218b/ios/ShareViewController/ShareViewController.swift#L193-L197
The folder is cleared at the start of each new share session, but that only removes/rewrites the file at that same fixed path — it doesn't change the URI the JS side ends up using: https://github.com/Expensify/App/blob/252374e047412ba7c271e162264f0bc283fa218b/ios/ShareViewController/ShareViewController.swift#L68-L87
On the JS side, the app renders the preview with expo-image (ExpoImage), whose source is the file:// URI produced from that on-disk path (tempFile.content → AttachmentPreview's source). expo-image caches images keyed by URI, not by file content/mtime:
https://github.com/Expensify/App/blob/252374e047412ba7c271e162264f0bc283fa218b/src/components/Image/BaseImage.native.tsx#L45-L54
Because handleImageData always reuses shared_image.png, the file://.../sharedFiles/shared_image.png URI never changes between share sessions. expo-image therefore returns its previously cached bitmap for that URI instead of reloading the freshly overwritten file, so the preview keeps showing the first receipt ever shared through this flow, no matter how many times the folder is cleared and rewritten on the native side.
What changes do you think we should make in order to solve the problem?
Give each shared image a unique filename in the Share Extension so the resulting file:// URI is different every time, which naturally busts expo-image's URI-keyed cache.
https://github.com/Expensify/App/blob/252374e047412ba7c271e162264f0bc283fa218b/ios/ShareViewController/ShareViewController.swift#L193-L197
let filename = "shared_image_\(UUID().uuidString).png"
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ChavdaSachin (External)
Proposal
Please re-state the problem that we are trying to solve in this issue.
When multiple receipts are shared into Expensify from iOS in separate attempts, the expense confirmation preview continues showing the first receipt instead of the latest shared image.
What is the root cause of that problem?
src/pages/iou/request/step/confirmation/useExpenseSubmission.ts correctly retrieves each receipt using receiptFiles[item.transactionID]. However, src/components/ReceiptImage/index.tsx passes the local receipt URI directly to ImageWithLoading. iOS commonly reuses the same temporary URI for shared screenshots, so the native image cache resolves that URI to the previously loaded bitmap even though a new transaction and file were supplied.
What changes do you think we should make in order to solve the problem?
In src/components/ReceiptImage/index.tsx, make local receipt previews reload when the transaction changes. Pass a source with iOS cache policy reload for local/file URIs and key ImageWithLoading by transactionID (falling back to the source URI). This forces the preview component and native image loader to read the current shared file instead of reusing the bitmap cached under the repeated temporary URI.
Add a focused test that rerenders ReceiptImage with a new transaction ID while using the same local URI and verifies that the image receives the reload cache policy and is remounted for the new receipt.
What alternative solutions did you explore? (Optional)
Clearing all image caches after every expense would also avoid the stale preview, but it is unnecessarily broad and would discard unrelated cached images. Scoping the reload to local receipt previews is safer.
Job added to Upwork: https://www.upwork.com/jobs/~022072372886498778552
Proposal
Please re-state the problem that we are trying to solve in this issue.
[$250] When sharing multiple files to create expenses in New Dot, the image preview shown is incorrect.
What is the root cause of that problem?
I traced this to the path that handles the issue-specific state:
- src/pages/workspace/expensifyCard/WorkspaceExpensifyCardListPage.tsx:188 (
navigate):onSelected: () => Navigation.navigate(ROUTES.WORKSPACE_EXPENSIFY_CARD_SETTINGS.getRoute(policyID)), - src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsApproverPage.tsx:82 (
if):if (shouldFilterOutExpensifyTeam && isExpensifyTeam(email) && visibleSelectedApproverEmail !== email) { - src/pages/workspace/expensifyCard/WorkspaceExpensifyCardListPage.tsx:201 (
shouldShowBulkSelectionDropdown):const shouldShowBulkSelectionDropdown = shouldUseNarrowLayout ? isMobileSelectionModeEnabled : selectedCardIDs.length > 0; - The local evidence matches this recurring failure shape: route params are created in one format and read in another. Here,
src/pages/workspace/expensifyCard/WorkspaceExpensifyCardListPage.tsx:188andsrc/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsApproverPage.tsx:82do not agree on the samethe issue-specific statevalue, so the user-visible path can show a missing or stale state even though nearby data already has the needed context.
What changes do you think we should make in order to solve the problem?
- Update
src/pages/workspace/expensifyCard/WorkspaceExpensifyCardListPage.tsx:188to derivethe issue-specific statefrom the route/access source that owns this flow before the value is consumed. - Carry the same normalized value through
src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsApproverPage.tsx:82; that follows the safer family move to fix the route builder/consumer pair instead of adding a screen-only redirect, so the write/optimistic/read paths agree instead of only changing the visible component. - Keep the change inside the Navigation, RHP, Not Here, Back Stack surface and avoid changing deep links, auth/onboarding redirects.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
- Add or update a regression in
tests/navigation/**/*.tsfor the exact issue flow: [$250] When sharing multiple files to create expenses in New Dot, the image preview shown is incorrect.. - Cover the counter-case near
src/pages/workspace/expensifyCard/WorkspaceExpensifyCardListPage.tsx:188so valid existingthe issue-specific statebehavior still works. - Manually repeat the issue steps after the patch and confirm the visible state/action is no longer stale.
What alternative solutions did you explore? (Optional)
- I would not add a broad new condition outside these referenced paths; the safer fix is to keep
the issue-specific stateconsistent at the first read/write boundary shown above.
⚠️ @KJ21-ENG Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.
Proposal [Updated]
Updated my proposal above with a more complete root-cause analysis and the full set of affected call sites.
Proposal
What is the root cause of that problem?
When an image (a screenshot, or anything iOS hands us as a UIImage) is shared into NewDot, the share extension writes it to disk with a hard‑coded filename:
https://github.com/Expensify/App/blob/a97126cd46a2293b01fceee52cb7ecdcbd442a4f/ios/ShareViewController/ShareViewController.swift#L193-L197
Every screenshot is saved to the exact same path …/sharedFiles/shared_image.png, so the content URI that the native module returns to JS ([fileURL absoluteString]) is byte‑for‑byte identical on every share:
https://github.com/Expensify/App/blob/a97126cd46a2293b01fceee52cb7ecdcbd442a4f/ios/RCTShareActionHandlerModule.m#L86-L102
For a PNG, shouldValidateFile is false (it only pre‑validates HEIC/IMG), so the preview binds directly to that raw URI:
https://github.com/Expensify/App/blob/a97126cd46a2293b01fceee52cb7ecdcbd442a4f/src/libs/ReceiptUtils.ts#L93-L95 https://github.com/Expensify/App/blob/a97126cd46a2293b01fceee52cb7ecdcbd442a4f/src/pages/Share/ShareDetailsPage.tsx#L80 https://github.com/Expensify/App/blob/a97126cd46a2293b01fceee52cb7ecdcbd442a4f/src/components/AttachmentPreview.tsx#L103-L106
AttachmentPreview feeds this URI into expo-image, whose cache key is the source URI:
https://github.com/Expensify/App/blob/a97126cd46a2293b01fceee52cb7ecdcbd442a4f/src/components/Image/BaseImage.native.tsx#L45-L54
Because the second share does not remount the app — ShareRootPage is already mounted and just re‑processes the file from the AppState foreground listener — the <Image> receives the same uri prop it had for the first receipt, and expo-image returns the already‑cached first image:
https://github.com/Expensify/App/blob/a97126cd46a2293b01fceee52cb7ecdcbd442a4f/src/pages/Share/ShareRootPage.tsx#L138-L156
So: fixed filename shared_image.png → identical content URI on every share → unchanged <Image> uri prop + URI‑keyed expo-image cache → the preview keeps showing the first receipt no matter how many you share.
(The extension clears the shared folder on every run — https://github.com/Expensify/App/blob/a97126cd46a2293b01fceee52cb7ecdcbd442a4f/ios/ShareViewController/ShareViewController.swift#L68-L87 — so the correct new bytes are on disk at that path; nothing on the JS side is stale except the URI‑keyed image cache. The same hard‑coded name also means two images shared in a single action overwrite each other, but the reported symptom is the cross‑share case.)
What changes do you think we should make in order to solve the problem?
Give each shared image a unique filename so the resulting content URI is distinct per share. This is the source of the identical‑URI collision, and fixing it here makes the URI change, which naturally busts the expo-image cache and triggers a re‑render with zero changes to any shared preview/image component:
private func handleImageData(_ image: UIImage, folder: URL, completion: @escaping (FileSaveError?) -> Void) {
os_log("Handling image data")
- let filename = "shared_image.png"
+ let filename = "shared_image_\(UUID().uuidString).png"
processAndSave(data: image.pngData(), filename: filename, folder: folder, completion: completion)
}
The extension already wipes the sharedFiles folder at the start of every share, so unique names never accumulate on disk. This also incidentally fixes the multi‑image‑in‑one‑share overwrite noted above.
Because production iOS is HybridApp, the identical change must also be applied to the corresponding share‑extension handleImageData in the Mobile-Expensify submodule (paired PR) — that is the extension that actually runs in staging/production. The App‑repo change above covers the standalone iOS build.
Minor details (exact naming/UUID vs timestamp) can be finalized in the PR phase.
What alternative solutions did you explore? (Optional)
A pure‑JS fix: force AttachmentPreview to remount and bypass the cache by keying it on the unique processedAt/id the native module already returns per call. This is heavier and less reliable — expo-image's memory cache is keyed by the URI, so a remount alone can still serve the cached bitmap for the same file:// path; fully busting it means threading a per‑render cacheKey/cachePolicy="none" through AttachmentPreview → Image, risking regressions for every other preview consumer. Making the URI unique at the source is smaller and side‑effect‑free.
Proposal
What is the root cause of that problem?
When a screenshot or image is shared to Expensify on iOS, the native share extension writes it to disk in the app group folder under a constant filename (shared_image.png).
As a result, the content URI returned to the JavaScript side is identical on every share (file://.../sharedFiles/shared_image.png). Because the app renders the preview using expo-image which caches images by their URI, subsequent shares continue displaying the first cached bitmap instead of loading the freshly written bytes from disk.
What changes do you think we should make in order to solve the problem?
We should move the shared file from the ephemeral sharedFiles directory to the app's durable receipts_upload directory on the JavaScript side as soon as it is received.
In ShareRootPage.tsx:
- Import
moveReceiptToDurableStoragefrom@libs/moveReceiptToDurableStorage. - Inside
handleProcessFiles, check if the processedtempFilehas a valid path and is not a text share (tempFile.mimeType !== 'txt'). - If it is a file path, extract its filename and use
moveReceiptToDurableStorage(tempFile.content, fileName)to generate a uniquely named copy in durable storage. - Update the
tempFileobject with the resolved durable URI before callingaddTempShareFile(tempFile)and executing validation.
This ensures each share has a unique URI to correctly bypass the image cache, requires zero native code changes, and prevents queued uploads from being deleted when the native extension clears the sharedFiles folder.
What alternative solutions did you explore? (Optional)
- Swift/Native Fix: Modifying
ShareViewController.swiftto use UUIDs. This was rejected because the production build depends on the extension code residing in theMobile-Expensifyrepository, meaning this path requires synchronized paired PRs. - JS Query-Param Cache-Busting: Appending query parameters like
?t=timestampto the local path. This was rejected because local file readers (such asfetchinsidereadFileAsync) can fail when local file URIs contain query strings.
Updated my proposal.
What changed: Updated the proposal to focus on generating unique iOS shared-file paths for each receipt image.
Why: The selected destination already clears the draft, while the preview cache can still reuse the unchanged local image URI.
Proposal
What is the root cause of that problem?
When a screenshot or gallery image is shared to NewDot through the iOS native share sheet, iOS hands the Share Extension an in-memory UIImage, so it goes through handleImageData, which always writes the file to the constant name shared_image.png inside the app-group sharedFiles folder:
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/ios/ShareViewController/ShareViewController.swift#L193-L197
On every new share setupSharedFolder wipes that folder and re-writes the file, so the bytes on disk are the new receipt but the absolute path never changes:
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/ios/ShareViewController/ShareViewController.swift#L68-L87
The native module then returns that path to JS as content ([fileURL absoluteString]), i.e. file://.../sharedFiles/shared_image.png, identical every time:
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/ios/RCTShareActionHandlerModule.m#L86-L100
That URI becomes the receipt source in the create-expense preview:
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/src/pages/Share/SubmitDetailsPage.tsx#L156
expo-image keys its memory cache on the source URI, so the second and later shares get the already-decoded first bitmap even though the file on disk changed. Notably the native module also returns a unique timestamp-based id, but the preview binds to content (the constant path), not id, so that uniqueness never reaches the image layer. That is exactly why 10 different receipts all preview the first one.
What changes do you think we should make in order to solve the problem?
- In
handleImageDatainShareViewController.swift, give each shared image a unique filename so the resultingcontentURI differs per share. BecausesetupSharedFolderalready clears the folder each run, unique names never accumulate:
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/ios/ShareViewController/ShareViewController.swift#L193-L197
let filename = "shared_image_\(UUID().uuidString).png"
processAndSave(data: image.pngData(), filename: filename, folder: folder, completion: completion)
A distinct URI on every share means expo-image no longer matches a cached entry, so the newly selected receipt is decoded and shown. This one change is the convergence point because content, the preview source, and the upload path all derive from this filename.
- Because production iOS is the HybridApp, apply the identical change to the paired
handleImageDatain theMobile-Expensifysubmodule the mobile app is built from that submodule):
The App-repo change covers the standalone iOS build; the submodule change covers staging/production.
What alternative solutions did you explore? (Optional)
A JS-only fix that avoids native changes: thread the already-unique native id/processedAt into the receipt preview in SubmitDetailsPage.tsx and set a reload/no-cache policy for local share URIs so the same file:// path re-decodes. This works without a paired native PR but must be applied to every preview sink and kept out of the readFileAsync upload path, so it is riskier than fixing the URI at the source.
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On iOS, sharing a screenshot into Expensify to create an expense shows the wrong image in the confirmation preview. The preview keeps showing the first receipt you shared instead of the one you just selected. Share ten different receipts one after another and the preview stays stuck on the first one every time.
What is the root cause of that problem?
The share extension saves every shared image to disk under the same hardcoded filename. In ios/ShareViewController/ShareViewController.swift:195, handleImageData sets let filename = "shared_image.png" for every screenshot that comes through the share sheet. A screenshot arrives as a UIImage, so it always takes the handleData → handleImageData path and always lands at file://.../group.com.expensify.new/sharedFiles/shared_image.png. The folder gets cleared and rewritten each session, so the bytes on disk are correct, but the absolute file URL is byte-for-byte identical on every share.
That URL becomes the file content in RCTShareActionHandlerModule.m:89 ([fileURL absoluteString]), flows through ShareRootPage → ShareActionHandler.processFiles → SubmitDetailsPage → MoneyRequestConfirmationList, and ends up as the uri on the preview <Image>. React Native caches decoded file:// images by their URI. Same URI means a cache hit, so RN hands back the first receipt it ever decoded and never re-reads the new file. The actual upload is fine because the file gets read from disk fresh at submit time. Only the preview is stale, which matches the report exactly. This is not a regression. shared_image.png has been the literal since the share extension first shipped in 8ab431ae42f.
What changes do you think we should make in order to solve the problem?
Give each shared image a unique filename so its file URL changes every share, which forces an RN cache miss and a fresh decode. In handleImageData at ios/ShareViewController/ShareViewController.swift:195:
let timestamp = Int(Date().timeIntervalSince1970 * 1000)
let filename = "\(timestamp)_shared_image.png"
The folder is already cleared each session, so only one file ever exists at a time. The timestamp prefix just guarantees a fresh URI. This lines up with what the native side already does for its id, which uses a <timestamp>_<filePath> scheme.
Worth flagging: the same collision exists for any reused filename. Text shares use the fixed text_to_read.txt and URL shares reuse url.lastPathComponent, both of which can produce an identical URI across shares. I'd keep this PR scoped to the image path since that's what's reported, but if we want to cover all share types the same prefixing could move into processAndSave/saveFileToFolder. That broader change affects getFileName(content) on the App side for the URL case, so I'd only do it if you'd prefer the fuller fix.
This needs manual iOS verification since it's the native share extension: share screenshot A, save it, then share screenshot B and confirm B shows in the preview, not A.
What alternative solutions did you explore? (Optional)
App-side cache busting, appending #${processedAt} to the Image uri so RN sees a new key. I rejected it because adding a fragment or query to a file:// path breaks readFileAsync at submit, and it means threading a second value through the confirmation list. Fixing the filename natively removes the collision at its source instead of papering over it downstream.
⚠️ @samranahm Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On iOS, when you share screenshots/gallery images into New Dot one after another to create expenses, the receipt preview keeps showing the first image you ever shared instead of the one you just selected. After N shares the preview is still stuck on the first receipt.
What is the root cause of that problem?
A screenshot/gallery image reaches the iOS share extension as an in-memory UIImage, so it goes through handleImageData, which always writes it to the app-group folder under the constant filename shared_image.png:
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/ios/ShareViewController/ShareViewController.swift#L193-L197
The native module hands that path to JS as content = [fileURL absoluteString], so every image share produces the identical URI file://.../sharedFiles/shared_image.png:
https://github.com/Expensify/App/blob/50fa144c4cf79fa8d6d99b237a7e9e4944146b64/ios/RCTShareActionHandlerModule.m#L86-L90
That URI becomes the receipt source in the create-expense preview:
https://github.com/Expensify/App/blob/55e5bed9baa19208127365c034a6ddaa1f635e00/src/pages/Share/SubmitDetailsPage.tsx#L169 https://github.com/Expensify/App/blob/55e5bed9baa19208127365c034a6ddaa1f635e00/src/pages/Share/SubmitDetailsPage.tsx#L450
The mechanism I want to point at specifically — because it explains why this is fixable without any native change — is what the app does with that URI when it renders it. Every image goes through BaseImage.native, which derives its expo-image identity from getImageRecyclingKey(source):
https://github.com/Expensify/App/blob/55e5bed9baa19208127365c034a6ddaa1f635e00/src/components/Image/BaseImage.native.tsx#L49-L50
and that helper collapses an object/string source straight down to the uri:
https://github.com/Expensify/App/blob/55e5bed9baa19208127365c034a6ddaa1f635e00/src/libs/getImageRecyclingKey.ts#L24-L28
expo-image also defaults its memory/disk cache key to the URI when no explicit cacheKey is given. So on every share both the recycling identity and the cache key resolve to the same constant string. The bytes on disk are the new receipt (the folder is wiped and rewritten each share), but expo-image sees an unchanged cache key, returns the already-decoded first bitmap, and never re-reads the file. That is the "always the first receipt" behavior.
Note the native module already returns a unique per-share id/processedAt that is threaded onto the shared file, but nothing feeds it to the image layer, so the uniqueness never reaches the cache:
https://github.com/Expensify/App/blob/55e5bed9baa19208127365c034a6ddaa1f635e00/src/types/onyx/ShareTempFile.ts#L4-L7
What changes do you think we should make in order to solve the problem?
Give the shared receipt image an explicit, per-share cacheKey derived from the already-unique ShareTempFile.id (or processedAt), instead of letting expo-image fall back to the constant URI. The uri stays a clean file:// path, so readFileAsync/upload is untouched, and only the cache identity changes — which is exactly what needs to differ per share.
Concretely, pass the source as an object carrying a cacheKey at the preview sinks. In AttachmentPreview (share-to-chat), instead of source={{uri: source}}:
<Image source={{uri: source, cacheKey: cacheKey ?? source}} ... />
and thread the same cacheKey (the file id) into the create-expense preview so MoneyRequestConfirmationList → ReceiptImage → ImageWithLoading → BaseImage receives an object source with the unique key. Because getImageRecyclingKey returns source.uri for object sources, the recycling behavior is unchanged; only the cache key becomes unique per share, so expo-image misses the cache and decodes the freshly written file every time.
The advantage over changing the native filename is that this is a standalone App-repo fix: production iOS is HybridApp built from the Mobile-Expensify submodule, so any native ShareViewController change needs a paired submodule PR to actually ship — the JS cacheKey fix lands in one repo and covers both the standalone and HybridApp builds.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
- Render the share/create-expense preview with a source whose
uriis unchanged but whoseidchanges, and assert the<Image>receives a newcacheKey(i.e. two consecutive shares of the same local path produce distinct cache keys). - A counter-case: the same
idre-rendered keeps a stablecacheKey(no needless remount/reload). - Manual iOS check: share receipt A through the native share sheet, save it, then share receipt B and confirm the preview and the saved expense both show B; repeat with three screenshots and confirm the preview never sticks on the first.
What alternative solutions did you explore? (Optional)
- Unique native filename in
handleImageData(e.g.shared_image_<uuid>.png). This fixes the URI at the source and is clean, but it lives in native share-extension code that production runs from theMobile-Expensifysubmodule, so it requires a paired native PR to actually ship. ThecacheKeyfix avoids that split and stays in one repo. - Cache-busting the URI in JS (append
?t=/#tocontent). Rejected: the same value is read as a real local file byreadFileAsyncat submit, and a query/fragment on afile://path can break that read.cacheKeychanges only the cache identity, leaving theuriintact.