Skip to content

[Due for payment 2026-07-16] [$250] Android: SmartScan shortcut re-navigates when already on SmartScan screen #88009

Closed

Description

@Julesssss

Follow up task from this PR. So no separate payment here for DylanDylann 🥲

Comment.


If you open SmartScan via the Android static shortcut, background the app, then long-press and tap "SmartScan" again, the app flickers and re-navigates from SmartScan to SmartScan unnecessarily.

This was observed during QA of Mobile-Expensify#13906 (trampoline activity fix). The same likely applies to the "Manually Create" shortcut.

The fix is expected to be a NewDot navigation-layer change — the app should detect it's already on the target screen and skip the redundant navigation.

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022051339307394222351
  • Upwork Job ID: 2051339307394222351
  • Last Price Increase: 2026-07-16

Activity

  1. DylanDylann commented on Apr 16, 2026

    @DylanDylann
    Contributor

    I think we should track this problem in the original issue

  2. Julesssss commented on Apr 17, 2026

    @Julesssss
    ContributorAuthor

    Fine by me, commented here.

  3. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on May 4, 2026
  4. melvin-bot commented on May 4, 2026

    @melvin-bot

    Current assignee @DylanDylann is eligible for the External assigner, not assigning anyone new.

  5. changed the title [-]Android: SmartScan shortcut re-navigates when already on SmartScan screen[/-] [+][$250] Android: SmartScan shortcut re-navigates when already on SmartScan screen[/+] on May 4, 2026
  6. melvin-bot commented on May 4, 2026

    @melvin-bot
  7. wildan-m commented on May 4, 2026

    @wildan-m
    Contributor

    Proposal

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

    Opening SmartScan via the Android static shortcut, backgrounding the app, then long-pressing the app icon and tapping "SmartScan" again causes NewDot to re-navigate from SmartScan to SmartScan. The user sees a visible flicker and the screen remounts even though the target tab is already visible. The same behavior is expected to apply to the "Manually Create" static shortcut. The fix is expected to live in the NewDot navigation layer: detect that the app is already on the target tab and drop the redundant navigation before it reaches React Navigation.

    What is the root cause of that problem?

    When an Android static shortcut is tapped, the host activity forwards the intent to NewDot as a deep link URL via Linking. The URL is received inside the React Navigation linking config's subscribe listener, which is where incoming URLs get a chance to be intercepted before the navigation tree reacts to them.

    That listener already contains a dedup guard, but only for the GPS distance screen:

    const subscribe: LinkingOptions<RootNavigatorParamList>['subscribe'] = (listener) => {
    const subscription = Linking.addEventListener('url', ({url}: {url: string}) => {
    // Skip GPS distance screen deep links when the user is already on that screen.
    // This prevents a re-navigation with animation when tapping the GPS live update notification
    // while the GPS screen is already visible.
    if (url.includes(ROUTES.DISTANCE_REQUEST_CREATE_TAB_GPS.route)) {
    const state = navigationRef.current?.getRootState();
    if (state) {
    const currentRoute = findFocusedRoute(state);
    if (currentRoute?.name === ROUTES.DISTANCE_REQUEST_CREATE_TAB_GPS.route) {
    return;
    }
    }
    }
    listener(url);
    });
    return () => subscription.remove();
    };

    The guard returns early when the URL targets distance-gps AND the currently focused route name is distance-gps, which is exactly the "already on the target tab" check needed here. This guard was added to kill the flicker from tapping the GPS live update notification while the GPS tab is already visible.

    For every other route — including the targets of the SmartScan and Manually Create Android shortcuts — the listener forwards the URL unchanged. React Navigation then resolves the URL against the linking config, sees a route path whose final segment is scan or manual, and fires a navigation action into the IOURequestStartPage tab navigator. Because that tab is already focused, React Navigation still processes the action (there is no built-in "already active, skip" dedup at this level), which remounts the tab subtree — producing the observed flicker.

    The IOURequestStartPage top tab navigator names its tabs after the CONST.TAB_REQUEST values ('scan', 'manual', 'distance-gps', etc.), which is why the existing GPS check can compare findFocusedRoute(state)?.name directly against ROUTES.DISTANCE_REQUEST_CREATE_TAB_GPS.route (which evaluates to 'distance-gps'). The same identity holds for ROUTES.MONEY_REQUEST_CREATE_TAB_SCAN.route ('scan') and ROUTES.MONEY_REQUEST_CREATE_TAB_MANUAL.route ('manual'):

    App/src/ROUTES.ts

    Lines 1595 to 1603 in 3d9b33b

    MONEY_REQUEST_CREATE_TAB_MANUAL: {
    route: 'manual',
    getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, backToReport?: string) =>
    `${action as string}/${iouType as string}/start/${transactionID}/${reportID}${backToReport ? `/${backToReport}` : ''}/manual` as const,
    },
    MONEY_REQUEST_CREATE_TAB_SCAN: {
    route: 'scan',
    getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, backToReport?: string) =>
    `create/${iouType as string}/start/${transactionID}/${reportID}${backToReport ? `/${backToReport}` : ''}/scan` as const,

    App/src/CONST/index.ts

    Lines 6264 to 6274 in 3d9b33b

    TAB_REQUEST: {
    MANUAL: 'manual',
    SCAN: 'scan',
    DISTANCE: 'distance',
    PER_DIEM: 'per-diem',
    DISTANCE_MAP: 'distance-map',
    DISTANCE_MANUAL: 'distance-manual',
    DISTANCE_GPS: 'distance-gps',
    DISTANCE_ODOMETER: 'distance-odometer',
    TIME: 'time',
    },

    So the reason the bug exists is narrow: the subscribe listener's dedup check was scoped to a single route constant at the time of its addition, and the Android static shortcut targets were never added to it. Any route not named in that check has no protection against a deep-link-driven re-navigation to the already-focused tab.

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

    Generalize the dedup guard in src/libs/Navigation/linkingConfig/subscribe.ts so that it also covers the Android static shortcut targets. Concretely:

    1. Introduce a small list of tab route names that must not be re-navigated when already active. The list starts with the existing GPS entry and adds the two routes the reported bug hits: ROUTES.DISTANCE_REQUEST_CREATE_TAB_GPS.route, ROUTES.MONEY_REQUEST_CREATE_TAB_SCAN.route, and ROUTES.MONEY_REQUEST_CREATE_TAB_MANUAL.route.
    2. For an incoming URL, determine which (if any) entry in this list the URL is targeting. Use a boundary-aware match — check whether the URL's path ends with /<route> or /<route>?... rather than a loose substring include — so that tokens like scan and manual cannot be matched inside unrelated URLs.
    3. If the incoming URL targets an entry in the list AND findFocusedRoute(navigationRef.current?.getRootState())?.name equals that same entry, return early without calling listener(url). Otherwise, forward the URL as before.

    This keeps the existing GPS behavior identical (the GPS route is still in the list, the focused-route comparison is still the same), and extends the same protection to the two shortcut-driven tabs named in the issue. The change is scoped to one file and one function, requires no SCREENS constants, and uses existing ROUTES and CONST.TAB_REQUEST values whose equality to tab navigator route names is already load-bearing for the current GPS guard.

    Because the dedup happens at the Linking subscription layer — before React Navigation sees the URL — the flicker is prevented at its source, whether the URL originates from an Android static shortcut, a live-update notification, or a share-sheet intent. No native Android changes are required; the trampoline activity fix in Mobile-Expensify#13906 already narrows the path down to the deep link URL that this guard intercepts.

    Expected behavior after the change:

    • Tapping the "SmartScan" static shortcut while the SmartScan tab is already focused → the URL is dropped, no navigation occurs, no flicker.
    • Tapping the "Manually Create" static shortcut while the Manual tab is already focused → same, no flicker.
    • Tapping either shortcut while on any other screen → normal navigation to the target tab, unchanged from today.
    • GPS distance screen behavior → unchanged (same code path, same result).

    What alternative solutions did you explore? (Optional)

    The fix could alternatively be placed inside the IOU action layer — specifically before each Navigation.navigate() call inside startMoneyRequest() and startDistanceRequest() in src/libs/actions/IOU/index.ts:

    switch (requestType) {
    case CONST.IOU.REQUEST_TYPE.MANUAL:
    Navigation.navigate(ROUTES.MONEY_REQUEST_CREATE_TAB_MANUAL.getRoute(CONST.IOU.ACTION.CREATE, iouType, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, reportID, backToReport));
    return;
    case CONST.IOU.REQUEST_TYPE.SCAN:
    Navigation.navigate(ROUTES.MONEY_REQUEST_CREATE_TAB_SCAN.getRoute(CONST.IOU.ACTION.CREATE, iouType, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, reportID, backToReport));
    return;
    case CONST.IOU.REQUEST_TYPE.DISTANCE:
    Navigation.navigate(ROUTES.MONEY_REQUEST_CREATE_TAB_DISTANCE.getRoute(CONST.IOU.ACTION.CREATE, iouType, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, reportID, backToReport));
    return;
    case CONST.IOU.REQUEST_TYPE.TIME:
    Navigation.navigate(ROUTES.MONEY_REQUEST_CREATE_TAB_TIME.getRoute(CONST.IOU.ACTION.CREATE, iouType, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, reportID, backToReport));
    return;
    default:
    Navigation.navigate(ROUTES.MONEY_REQUEST_CREATE.getRoute(CONST.IOU.ACTION.CREATE, iouType, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, reportID, backToReport));
    }

    Each case currently calls Navigation.navigate(ROUTES.MONEY_REQUEST_CREATE_TAB_*.getRoute(...)) unconditionally; adding a Navigation.getActiveRouteWithoutParams() comparison before each call would also suppress the redundant navigation.

    I did not choose this location for three reasons. First, the issue description explicitly points to "a NewDot navigation-layer change" and the linking subscription layer is the navigation layer for deep-link URLs — the IOU action layer is a different concern. Second, subscribe.ts already contains the prior-art dedup for the GPS case, so generalizing it keeps a single place that owns "don't re-navigate into a tab you're already on" instead of duplicating the same idea at both the linking layer and the IOU action layer. Third, startMoneyRequest() is also called by in-app flows (FAB menu, keyboard shortcuts, QuickActionNavigation.ts) which rely on the accompanying clearMoneyRequest(...) call inside the function to reset draft state; skipping the navigate there would still leave the draft cleared, which could surprise callers that depend on the re-mount to rebuild transient UI state. Fixing at the linking subscription layer affects only deep-link-driven navigations and leaves in-app paths untouched.

    Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/88009-dedup-shortcut-deep-link?expand=1

  8. 48 remaining items

  9. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Jul 10, 2026
  10. melvin-bot commented on Jul 15, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  11. melvin-bot commented on Jul 15, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    • Contributor: @war-in does not require payment (Contractor)
    • Reviewer: @DylanDylann owed $250 via NewDot

    BugZero Checklist (@mallenexpensify)

    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/2051339307394222351/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  12. melvin-bot commented on Jul 16, 2026

    @melvin-bot

    📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

  13. mallenexpensify commented on Jul 17, 2026

    @mallenexpensify
    Contributor

    Follow up task from https://github.com/Expensify/Mobile-Expensify/pull/13906 PR. So no separate payment here for DylanDylann 🥲

    ^ Test case created. Thx

    Closing

  14. gijoe0295 commented on Jul 18, 2026

    @gijoe0295
    Contributor

    @mallenexpensify I think I'm due payment here because I implemented the PR cc @Julesssss

  15. mallenexpensify commented on Jul 20, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @gijoe0295 due $250 via NewDot

    oops, missed that. Sorry @gijoe0295

  16. JmillsExpensify commented on Jul 22, 2026

    @JmillsExpensify
    Contributor

    $250 approved for @gijoe0295

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 productionDailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions