Skip to content

[Due for payment 2026-04-28] [Due for payment 2026-03-30] Android - Scan - App returns to confirm page after tapping Replace #85696

Closed

Description

@lanitochka17

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.3.40-0
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #83899
Email or phone of affected tester (no customers): sdjsdjosijnsodiosd@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Samsung Galaxy S25 FE / Android 16
App Component: Money Requests

Action Performed:

  1. Launch Expensify app.
  2. Go to workspace chat.
  3. Tap + > Create expense > Scan.
  4. Upload a photo.
  5. On confirm page, tap on the receipt.
  6. Tap Replace.

Expected Result:

Replace receipt page will open.

Actual Result:

App returns to confirm page after tapping Replace.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Bug7106302_1773843536694.13.mp4

View all open jobs on GitHub

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Mar 18, 2026
  2. melvin-bot commented on Mar 18, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #83899

  3. melvin-bot commented on Mar 18, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  4. github-actions commented on Mar 18, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  5. OSBotify commented on Mar 18, 2026

    @OSBotify
    Contributor

    🔍 Investigation Summary

    Classification: Frontend bug
    Causing PR: #83899 - "Migration navigation from InteractionManager to TransitionTracker V2" by @collectioneur (High confidence)
    Related Issues: #85687 (same root cause), part of #71913 (TransitionTracker migration parent issue)

    Recommendation: REVERT

    PR #83899 introduces the TransitionTracker system to replace InteractionManager for handling navigation transitions. The bug occurs when tapping "Replace" on a receipt in the confirmation page - instead of navigating to the replace receipt page, the app returns to the confirm page.

    This is one of several Android-specific navigation failures introduced by this PR, all sharing the same root cause.

    Labels: No changes needed. DeployBlockerCash is correctly applied (blocks App deploy). Issue is not reproducible on production, only staging, confirming it was introduced in this deploy.

    📋 Detailed Analysis

    Evidence

    Verification

    The PR modified src/pages/media/AttachmentModalScreen/routes/TransactionReceiptModalContent.tsx at lines 521-527.

    Before (working on production):

    if (isNative) {
        Navigation.goBack();
        Navigation.setNavigationActionToMicrotaskQueue(() => {
            Navigation.navigate(getDestinationRoute());
        });
        return;
    }
    
    Navigation.dismissModal({
        callback: () => Navigation.navigate(getDestinationRoute()),
    });

    After (broken on staging):

    Navigation.dismissModal({
        afterTransition: () => Navigation.navigate(getDestinationRoute()),
    });

    The PR removed the Android-specific navigation flow that used goBack() + setNavigationActionToMicrotaskQueue() and replaced it with the unified dismissModal({ afterTransition }) approach powered by TransitionTracker.

    Root Cause

    The TransitionTracker system relies on transitionStart and transitionEnd events from React Navigation to track when transitions complete. The dismissModal function with afterTransition calls:

    TransitionTracker.runAfterTransitions({
        callback: afterTransition,
        waitForUpcomingTransition: true
    });

    The waitForUpcomingTransition: true flag creates an async flow that waits for the next startTransition() call before queuing the callback.

    On Android with @react-navigation/native-stack, the Fragment-based screen management can cause the ScreenLayout component to be torn down before the transitionEnd event fires for the disappearing screen. This leaves startTransition() called (incrementing activeCount) but the corresponding endTransition() never fires, leaving activeCount stuck at a positive value.

    While there's a 1000ms safety timeout, the accumulated transition imbalance means the afterTransition callback (which navigates to the replace receipt page) gets queued but waits indefinitely for activeCount to reach 0. From the user's perspective, nothing happens when they tap "Replace" - they just return to the confirm page.

    This is Android-specific because of how react-native-screens manages Fragment lifecycle differently than iOS UIKit.

  6. Pujan92 commented on Mar 18, 2026

    @Pujan92
    Contributor

    Strange, @lanitochka17 I don't see the issue in emulator

    f1.webm
  7. MelvinBot commented on Mar 18, 2026

    @MelvinBot
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On Android, when viewing a scanned receipt in the attachment modal and tapping "Replace", the app dismisses the modal but never navigates to the Replace receipt page. The user is left on the confirm page with no way to replace the receipt (other than starting over). This is a regression introduced by PR #83899 which migrated from InteractionManager to TransitionTracker.

    What is the root cause of that problem?

    PR #83899 replaced a native-specific code path in TransactionReceiptModalContent.tsx with a unified dismissModal({ afterTransition }) call. The old code used Navigation.goBack() + setNavigationActionToMicrotaskQueue() which reliably deferred the navigation. The new code relies on TransitionTracker to detect when the dismiss transition completes.

    The problem is a race condition between React component unmount and native transition events on Android's native-stack navigator:

    1. dismissModal dispatches DISMISS_MODAL (a pop action), removing the attachment modal route from the navigation state.
    2. NativeStackView re-renders without the popped screen — React unmounts the ScreenLayout component for that screen, which removes the transitionStart/transitionEnd event listeners.
    3. The afterTransition callback is registered via TransitionTracker.runAfterTransitions({ waitForUpcomingTransition: true }), which awaits promiseForNextTransitionStart before queuing.
    4. The native ScreenStack begins the exit animation and fires onWillDisappear/onDisappear callbacks — but since the React component was already unmounted, these events either don't reach JS or their listeners are gone.
    5. If startTransition() is never called for the popped screen, and no other transition fires, promiseForNextTransitionStart never resolves and the afterTransition callback (which navigates to the Replace receipt page) is permanently lost.

    On web, this doesn't happen because the attachment modal uses ReanimatedModal which has its own independent TransitionTracker.startTransition()/endTransition() calls. On native, the attachment modal is a plain native stack screen (AttachmentModalContainer/index.native.tsx renders a ScreenWrapper, not a Modal), so the only transition tracking comes from ScreenLayout — which is subject to the unmount race.

    Key code locations:

    • src/pages/media/AttachmentModalScreen/routes/TransactionReceiptModalContent.tsx ~line 525: the dismissModal({ afterTransition }) call
    • src/libs/Navigation/Navigation.ts ~line 765-779: dismissModal registers afterTransition with waitForUpcomingTransition: true
    • src/libs/Navigation/TransitionTracker.ts ~line 104-122: waitForUpcomingTransition awaits promiseForNextTransitionStart
    • src/libs/Navigation/PlatformStackNavigation/ScreenLayout.tsx ~line 22-34: listeners are removed on unmount

    What changes do you think we should make in order to solve the problem?

    Restore the native-specific code path in TransactionReceiptModalContent.tsx that was removed by PR #83899. The old approach used Navigation.goBack() + Navigation.setNavigationActionToMicrotaskQueue() which doesn't depend on TransitionTracker detecting transition events and is reliable on native platforms.

    Specifically, re-add the isNative check in the Replace handler so that on native platforms, the code calls Navigation.goBack() followed by setNavigationActionToMicrotaskQueue(() => Navigation.navigate(getDestinationRoute())) instead of Navigation.dismissModal({ afterTransition }).

    What alternative solutions did you explore? (Optional)

    1. Call endTransition() in ScreenLayout's cleanup function — This would prevent the activeCount leak, but doesn't address the case where startTransition() for the popped screen never fires at all (meaning promiseForNextTransitionStart may never resolve).

    2. Track transitions at the navigator level instead of per-screen — This is a more architectural fix to TransitionTracker that would avoid the unmount race entirely, but has a much larger scope and risk.

    3. Call startTransition()/endTransition() directly in dismissModal — This would ensure the promise resolves, but conflates the transition tracking abstraction and could cause double-counting.

    The simplest and safest fix for this deploy blocker is option 1 in the main proposal: restore the proven native code path.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  8. m-natarajan commented on Mar 19, 2026

    @m-natarajan

    Issue no longer reproducible on build 9.3.40-3. Retested on Motorola Moto G60 - Android 12

    screen-20260318-223908.mp4
  9. 9 remaining items

  10. melvin-bot commented on Mar 23, 2026

    @melvin-bot

    @srikarparsi The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  11. melvin-bot commented on Mar 23, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  12. mallenexpensify commented on Mar 30, 2026

    @mallenexpensify
    Contributor

    If the regression penalty applies, comment on the issue linked to the PR that introduced the regression. Thx

  13. melvin-bot commented on Apr 17, 2026

    @melvin-bot

    ⚠️ Looks like this issue was linked to a Deploy Blocker here

    If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

    If a regression has occurred and you are the assigned CM follow the instructions here.

    If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

  14. changed the title [-][Due for payment 2026-03-30] Android - Scan - App returns to confirm page after tapping Replace[/-] [+][Due for payment 2026-04-28] [Due for payment 2026-03-30] Android - Scan - App returns to confirm page after tapping Replace[/+] on Apr 21, 2026
  15. melvin-bot commented on Apr 21, 2026

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  16. melvin-bot commented on Apr 21, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.60-22 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2026-04-28. 🎊

  17. melvin-bot commented on Apr 21, 2026

    @melvin-bot

    @srikarparsi @mallenexpensify The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2Engineering

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions