[Due for payment 2026-11-19] [$175] iOS: Reduce delay when navigating back from receipt preview
Users experience a noticeable delay after pressing the back arrow on the receipt preview screen. Users also tap the adjacent “Receipt” title, which does nothing.
Reported impact: 4,944 dead clicks from 2,287 users. The reporter also reproduced the delay on their phone.
Primary goal: Analyze and improve this flow’s performance. Pressing Back should return users to the previous screen with little to no perceptible delay.
Investigation:
- Measure time from pressing Back to completing navigation on iOS.
- Identify and remove work that delays navigation.
- Assess the back button’s touch target and users’ expectation that tapping “Receipt” navigates back.
Acceptance criteria: Verify near-instant back navigation on iOS and document before-and-after timings.
FullStory examples:
Source: Slack discussion
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022117690136938476125
- Upwork Job ID: 2117690136938476125
- Last Price Increase: 2026-11-03
Issue Owner
Current Issue Owner: @Ollyws
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Ollyws (External)
Job added to Upwork: https://www.upwork.com/jobs/~022117690136938476125
🤖 Web test steps verification results: ❌ fail
Blocked on dev NewDot web: Spend shows “No expenses yet,” so no expense receipt fixture was available. This provides no iOS performance confirmation.
| Step | Status |
|---|---|
Open an expense receipt previewNavigated to Spend; snapshot showed “No expenses yet.” No receipt preview was accessible.![]() |
❌ |
Tap Receipt title and observe navigationNot tested: receipt fixture unavailable. |
❌ |
Press Back and observe return behaviorNot tested: receipt preview could not be opened. No timing measurements taken. |
❌ |
Proposal
What is the root cause of that problem?
Medium confidence: iOS receipt Back waits for a future transition before dispatching the navigation that would start it. When idle, this adds a configured 1,000 ms wait before dismissal. This is code evidence, not measured iOS performance.
The adjacent “Receipt” title is separately noninteractive. Reported dead-click totals do not distinguish these two causes.
What changes do you think we should make in order to solve the problem?
Remove the upcoming-transition wait from the iOS attachment close handler, while retaining waits for transitions already running. Do not shorten the global timeout or disable animations.
Confirm the title’s intended interaction before expanding the Back target; that alone will not fix the delay.
Evidence and required validation
- Native close:21–43 defers navigation through the iOS handler:6–17.
- TransitionTracker:159–195 waits for a future transition or the 1,000 ms timeout:369–370. No navigation starts before this wait.
- Receipt configuration:629–654 disables the carousel. Expensive receipt teardown remains unproven; the scheduling wait is independent of normal dismissal animation.
- Header:124–138 renders the title without a navigation handler.
- Add tests for immediate idle close, active-transition waiting, and one navigation dispatch. Regression-test chat attachment dismissal and receipt replacement because the handler is shared.
- Measure tap → navigation dispatch → transition completion before and after on iOS, with image/PDF receipts and settled/in-progress opening animations. Web testing lacked a receipt fixture; no iOS timings or FullStory sessions were verified.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/105797) 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.
Pressing Back from the iOS receipt preview reportedly causes a noticeable delay. Users also tap the adjacent “Receipt” title without triggering navigation, but the supplied click totals do not establish how many interactions belong to each problem.
The fix must demonstrate improved Back navigation with before-and-after iOS timings and assess the header’s touch target separately.
What is the root cause of that problem?
The root cause remains unverified. MelvinBot identifies a plausible scheduling problem, but does not provide sufficient evidence to establish it as the cause of the reported delay.
The supplied proposal points to these locations at commit 211cebaff354c6529036fc7d927ee88f56ace555:
| Referenced location | Claim requiring verification |
|---|---|
src/pages/media/AttachmentModalScreen/AttachmentModalContainer/index.native.tsx:21–43 |
Close defers navigation through the attachment handler. |
src/libs/AttachmentModalHandler/index.ios.ts:6–17 |
The handler requests a future-transition wait before navigating. |
src/libs/Navigation/TransitionTracker.ts:159–195 |
That request can remain pending until a transition or timeout. |
src/CONST/index.ts:369–370 |
The configured timeout is 1,000 ms. |
These are references supplied by MelvinBot, not independently verified findings. Source retrieval failed, no Expensify checkout is available locally, and no iOS trace or Jest execution was possible.
Three claims therefore remain unsupported:
- A configured 1,000 ms timeout does not prove a measured 1,000 ms delay. Verification requires the actual invocation arguments, timer behavior, transition events, and navigation dispatch timestamps.
- The wait has not been shown to explain the reported sessions. No trace connects a receipt Back press to that pending wait.
- Removing the wait has not been shown to preserve its original ordering requirement. The handler’s other callers and the reason for introducing the wait require inspection.
What changes do you think we should make in order to solve the problem?
Refine MelvinBot’s proposal before implementation approval. Its scheduling hypothesis is credible enough to investigate, but neither a production fix nor the acceptance criterion has been demonstrated.
If source inspection and a failing regression test confirm the hypothesis, the minimal candidate change is confined to:
src/libs/AttachmentModalHandler/index.ios.ts
Change only the close-path behavior that waits for a transition which dismissal itself must initiate. Preserve synchronization with transitions already running, provided the tracker’s verified API supports that distinction.
An exact TypeScript diff cannot responsibly be supplied from the available evidence. The prompt contains no source snippets, and guessing the function signature, option name, or promise behavior would violate the requirement for exact, valid code.
Before selecting that edit:
- Establish whether repeated close requests already have protection against multiple navigation dispatches.
- Verify the ordering of cleanup, dismissal, callbacks, and receipt replacement.
- Inspect the shared handler’s callers to determine whether a handler-level change is appropriate.
- Assess the current Back target’s dimensions and accessibility behavior. Decide whether the receipt title belongs inside that target based on the intended interaction.
Do not add a new debounce, global title handler, or transition-tracker refactor without evidence that it is necessary.
For performance validation, record these timestamps on the same iPhone, iOS version, build configuration, and receipt fixtures before and after:
t0: Back press handler entry
t1: navigation dispatch
t2: closing transition start
t3: closing transition end / previous screen interactive
Report t1 − t0 separately from t3 − t0. Removing a scheduling wait does not eliminate the normal dismissal animation.
Current validation status: no measured baseline, no measured improvement, and no demonstrated acceptance-criteria pass.
What alternative solutions did you explore? (Optional)
MelvinBot’s proposal should be complemented with evidence, not attacked with invented defects. It already acknowledges uncertainty and proposes retaining active-transition waits.
Its unresolved cases are:
- Repeated presses: two pending close requests could produce multiple dispatches if no existing guard prevents this. That risk needs a test; it is not a demonstrated bug.
- Opening transition in progress: removing a wait indiscriminately could alter navigation ordering. The proposal must show which tracker behavior remains.
- Shared callers: receipt replacement and chat attachment dismissal need regression coverage before changing a shared iOS handler.
- Causal uncertainty: title dead clicks and slow dismissal are different observations. Neither proves the other’s cause.
Shortening the global timeout has a wider regression surface. Making the title clickable alone does not address a demonstrated navigation delay. There is no evidence supporting the assertion that any proposed solution is “the only safe” fix.
What automated tests can you add to prevent this from re-occurring?
Add focused Jest tests against the actual iOS handler and transition tracker, using fake timers and controlled transition events. Mock navigation dispatch, but do not mock away the scheduling behavior under investigation.
| Test | Required assertion |
|---|---|
| Idle dismissal | After required promise flushing, navigation dispatch occurs without advancing the configured future-transition timeout. This must fail before the fix. |
| Active opening transition | Dismissal respects the verified active-transition contract and dispatches once when that transition completes. |
| Repeated close requests | Repeated presses do not pop the underlying screen or produce duplicate close callbacks. |
| Late transition or timeout | After dismissal dispatch, subsequent events and timer advancement do not dispatch again. |
| Receipt replacement | The existing replacement flow preserves its required navigation and callback ordering. |
If the touch target changes, add a component test that presses the receipt title and verifies one Back action, followed by device checks for layout and accessibility.
These are proposed tests, not executed results. Jest can verify scheduling and dispatch behavior; the required before-and-after navigation timings still need iOS device measurements.
Contributor details
Your Expensify account email: [email protected]
Upwork Profile Link: https://www.upwork.com/freelancers/~01b60d704ba377be83
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Proposal
What is the root cause of that problem?
On native, Back calls closeScreen, which sends the close through attachmentModalHandler.handleModalClose:
https://github.com/Expensify/App/blob/c1d6b5234110fd81cc99e941e3fa5403e41b38df/src/pages/media/AttachmentModalScreen/AttachmentModalContainer/index.native.tsx#L33-L44
The iOS handler (and only the iOS one) wraps the close in TransitionTracker.runAfterTransitions({..., waitForUpcomingTransition: true}):
https://github.com/Expensify/App/blob/c1d6b5234110fd81cc99e941e3fa5403e41b38df/src/libs/AttachmentModalHandler/index.ios.ts#L12-L17
waitForUpcomingTransition means "if no screen transition is running, wait until the next one starts" (up to MAX_TRANSITION_START_WAIT_MS = 1000 ms):
https://github.com/Expensify/App/blob/c1d6b5234110fd81cc99e941e3fa5403e41b38df/src/libs/Navigation/TransitionTracker.ts#L171-L200
https://github.com/Expensify/App/blob/c1d6b5234110fd81cc99e941e3fa5403e41b38df/src/CONST/index.ts#L370
But the only transition that could start here is the back navigation that the callback (Navigation.goBack()) starts itself. So when the preview is idle, the close always sits out the full 1000 ms timeout before it navigates. The Android/Web handler (index.ts) calls the callback straight away, which is why only iOS is slow.
This handler was added in #53108 specifically to remove a close delay (#52937). Its comment still says it should run "after all interactions and animations have completed", meaning only wait if something is already animating. The waitForUpcomingTransition: true flag adds a wait for an animation that hasn't started yet, so the delay is back.
There is a second problem that makes the dead clicks worse: closeScreen has no guard. Every Back tap during that second (or during the closing animation) schedules another close(), so after the timeout Navigation.goBack() runs once per tap. That can also pop the report underneath the preview.
What changes do you think we should make in order to solve the problem?
- In
AttachmentModalHandler/index.ios.ts, keeprunAfterTransitionsbut dropwaitForUpcomingTransition. If the opening animation is still running, the close still waits for it to finish (which keeps the #52937 protection). When idle, it closes on the same tap. Update the comment there to explain why it must not wait for an upcoming transition. - In
AttachmentModalContainer/index.native.tsx, makecloseScreenrun only once per mount (anisClosingRefchecked at the top). Extra taps while closing then do nothing instead of sending moregoBackcalls. This works on both iOS and Android. - Tests:
tests/unit/AttachmentModalHandlerTest.ts: the iOS handler closes immediately when idle (fails on main, where it waits 1000 ms), still waits for a running transition, and runs the callback once. The Android/Web handler closes immediately.tests/ui/AttachmentModalContainerNativeTest.tsx, for both the iOS and Android handlers: Back callsgoBackimmediately (fails on main for iOS), and three quick taps callgoBackonly once (fails on main for both).
I won't change the global timeout or TransitionTracker itself, because other callers rely on waitForUpcomingTransition when they wait for a navigation they started before the call.
What alternative solutions did you explore? (Optional)
- Make the "Receipt" title tappable as a back target (the issue asks about this). It's a UX decision, so I'd suggest it as a follow-up once design confirms it. Once Back responds instantly, there should be far fewer dead clicks on the title.
- Skip the handler (
shouldCallDirectly) only for receipts, since they don't show a carousel. That fixes receipts, but chat attachments, which use the same handler, would keep the 1 s delay.
📣 @AmirSalahY! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:
- Make sure you've read and understood the contributing guidelines.
- Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
- Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
- Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
Proposal
Please re-state the problem that we are trying to solve in this issue.
On iOS, when users press the Back button from the receipt preview screen, there is a noticeable 1-second delay/freeze before the screen dismisses, causing users to repeatedly tap the Back button and the adjacent "Receipt" header title (resulting in thousands of dead clicks).
What is the root cause of that problem?
When closing the attachment modal on native iOS:
-
Stalling in
AttachmentModalHandler/index.ios.ts: Insrc/pages/media/AttachmentModalScreen/AttachmentModalContainer/index.native.tsx(lines 33-45), tapping Back invokesattachmentModalHandler.handleModalClose(close). Insrc/libs/AttachmentModalHandler/index.ios.ts(lines 12–17):TransitionTracker.runAfterTransitions({ callback: () => { onCloseCallback?.(); }, waitForUpcomingTransition: true, });Notice
waitForUpcomingTransition: true. -
The 1,000ms Timeout Freeze in
TransitionTracker.ts: Insrc/libs/Navigation/TransitionTracker.ts(lines 171–191):if (waitForUpcomingTransition && activeNavigationCount === 0) { ... const transitionStartTimeout = new Promise<void>((resolve) => { transitionStartTimeoutId = setTimeout(() => { didTimeout = true; resolve(); }, maxWaitForUpcomingTransitionMs); });When the user is viewing a settled receipt and taps Back,
activeNavigationCount === 0because no navigation transition is in progress. BecausewaitForUpcomingTransitionistrue,TransitionTrackerdoes not executeonCloseCallbackimmediately. Instead, it waits for an upcoming transition to begin. However, no other interaction or code initiates an upcoming transition while the modal is idle—onCloseCallbackitself is what initiatesNavigation.goBack()! As a result,TransitionTrackersits completely idle for the entiremaxWaitForUpcomingTransitionMs(CONST.MAX_TRANSITION_START_WAIT_MS= 1,000ms = 1 full second), timing out with:[TransitionTracker] waitForUpcomingTransition timed out before a transition startedOnly after this 1-second timeout does it executeonCloseCallback?.(), which finally dispatchesNavigation.goBack(). This is the exact root cause of the perceptible delay. -
Dead clicks on "Receipt" title: Because of the 1-second freeze, users believe their tap was missed and repeatedly tap the Back arrow and the adjacent non-interactive "Receipt" title (
HeaderTitleinHeaderWithBackButton/index.tsx), resulting in the 4,944 dead clicks logged in FullStory.
What changes do you think we should make in order to solve the problem?
-
Remove
waitForUpcomingTransitioninsrc/libs/AttachmentModalHandler/index.ios.ts:const attachmentModalHandler: AttachmentModalHandler = { handleModalClose: (onCloseCallback) => { TransitionTracker.runAfterTransitions({ callback: () => { onCloseCallback?.(); }, }); }, };- When any active transitions/animations are already running (such as modal open animation or carousel swipe),
runAfterTransitionsstill waits for those active transitions to finish before dismissing, preserving the visual stability intended by issue #52937. - When the preview is idle/settled (
activeTransitions.size === 0),runAfterTransitionsinvokesonCloseCallbacksynchronously and immediately, eliminating the 1,000ms delay entirely.
- When any active transitions/animations are already running (such as modal open animation or carousel swipe),
-
Touch Target & Header Responsiveness (Optional enhancement in
HeaderWithBackButton/index.tsx):- Provide standard
hitSlopto the Back button pressable (CONST.HIT_SLOP.DEFAULT), ensuring finger taps near the arrow boundary register smoothly. - If design approves, allow tapping the "Receipt" title in the modal header to also invoke
onBackButtonPress.
- Provide standard
What alternative solutions did you explore? (Optional)
- Lowering
CONST.MAX_TRANSITION_START_WAIT_MSglobally: This would affect other navigation transition queues across the app and would still retain an artificial latency when dismissing settled modals. RemovingwaitForUpcomingTransitionwhen closing idle modals is the architecturally correct fix.
Automated Tests
Add unit tests in tests/unit/libs/AttachmentModalHandlerTest.ts:
- Verify that when no transitions are active,
handleModalCloseexecutesonCloseCallbackimmediately with 0ms delay. - Verify that if an active transition is ongoing,
onCloseCallbackexecutes as soon as the transition completes.
Manual Tests
- On iOS, open Expensify and navigate to an expense with a receipt.
- Tap the receipt to open the full-screen receipt preview.
- Tap the Back button in the top-left corner.
- Verify the receipt preview dismisses immediately without any 1-second lag or hesitation.
- Verify on other attachment modals (e.g. image previews in chat) that dismiss animations remain smooth with no visual regressions.
Contributor details
Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0105126232377c4c5c
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
@MelvinBot Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~013282915b8b8bbb19
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
@MelvinBot what code changes would this involve?
The minimal candidate fix changes one production file, plus regression tests. Remove waitForUpcomingTransition: true from src/libs/AttachmentModalHandler/index.ios.ts:12–17, leaving:
TransitionTracker.runAfterTransitions({
callback: () => {
onCloseCallback?.();
},
});
Also update the nearby comment: wait for existing transitions, not a future transition that closing must initiate.
Tests and scope
- Add iOS-handler tests using the real tracker and fake timers: idle close calls back immediately; active transitions delay the callback until completion; later timer advancement does not invoke it again.
- The tracker’s existing behavior:159–212 already supports this. No global timeout, tracker, or animation changes are needed.
- Keep the title/touch-target change separate pending design confirmation. A repeated-close guard is additional hardening, not required to remove this wait; test repeated taps before deciding whether to add it.
- Validate receipt Back, chat attachment dismissal, and receipt replacement on iOS. Before-and-after timings are still required; this candidate has not been device-validated.
Triggered auto assignment to @MonilBhavsar, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
@Ollyws 👍 feel free to implement
@MelvinBot implement this
Implemented in draft PR: Avoid waiting for a future transition when closing iOS attachments, assigned to Ollyws.
- Removed the future-transition wait while retaining waits for active transitions; receipt title behavior is unchanged.
- Added four regression cases. All 32 focused handler/tracker tests pass, including cases that failed before the change.
- Changed-file lint, spelling, app/Jest typechecks, and coding-standards review passed.
Still required: iOS before-and-after timings and dismissal/replacement regression checks. Repository-wide checks timed out, and formatting verification was unavailable; details are in the PR’s AI Tests section.
Please complete the remaining validation before marking the draft ready for review.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On iOS, pressing the Back arrow on the receipt preview screen (AttachmentModalScreen) has a noticeable ~1 second delay before the screen navigates back, leading users to repeatedly tap the Back arrow and the adjacent "Receipt" title.
What is the root cause of that problem?
In src/pages/media/AttachmentModalScreen/AttachmentModalContainer/index.native.tsx (lines 33–45), pressing the Back button calls closeScreen, which passes the navigation close callback through attachmentModalHandler.handleModalClose. On iOS only (src/libs/AttachmentModalHandler/index.ios.ts, lines 12–17), handleModalClose calls:
TransitionTracker.runAfterTransitions({callback: () => { onCloseCallback?.(); }, waitForUpcomingTransition: true}).
In src/libs/Navigation/TransitionTracker.ts (lines 171–200), waitForUpcomingTransition: true means that when activeNavigationCount === 0 (the receipt preview screen is completely idle), TransitionTracker waits up to CONST.MAX_TRANSITION_START_WAIT_MS (1000ms in src/CONST/index.ts, line 370) for a new transition to start before running callback. Because the back navigation transition is started by onCloseCallback itself (Navigation.goBack()), no transition ever starts while waiting, forcing every Back press on iOS receipt preview to stall for the full 1,000ms timeout before navigating.
What changes do you think we should make in order to solve the problem?
- In
src/libs/AttachmentModalHandler/index.ios.ts(lines 12–17), removewaitForUpcomingTransition: truefromTransitionTracker.runAfterTransitions, leaving:TransitionTracker.runAfterTransitions({callback: () => { onCloseCallback?.(); }}). This still waits for any currently active transition to finish before closing, while executingonCloseCallbackimmediately when the screen is idle. - Add a unit test in
tests/unit/AttachmentModalHandlerTest.tsusing fake timers to verify thatattachmentModalHandler.handleModalCloseon iOS invokesonCloseCallbackimmediately when no transition is active and waits only when a transition is already in progress.
What alternative solutions did you explore? (Optional)
We considered reducing CONST.MAX_TRANSITION_START_WAIT_MS globally, but waitForUpcomingTransition: true is fundamentally wrong when the callback itself is what initiates the transition, so removing waitForUpcomingTransition: true in AttachmentModalHandler/index.ios.ts eliminates the entire 1,000ms wait.