Skip to content

[Submit] Submit via PDF-The report does not load #97851

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: v9.4.50-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: #97216
Email or phone of affected tester (no customers): applausetester+ag300726@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Samsung S23FE/ Android 16
App Component: Money Requests

Action Performed:

Preconditions:
As User A (expensifail account), create a Submit workspace in OD.
Navigate to ND, create an expense in the workspace.
Open the expense, click the dropdown on the Submit button, select "Submit via PDF".

  1. Sign out of User A
  2. Kill the Expensify app (not just backgrounded)
  3. Open the PDF from preconditions
  4. Tap the "Approve or Pay online" button
  5. When redirected to the Sign in screen, enable Use Staging Server
  6. Sign in with a new Gmail account

Expected Result:

The report is loaded.

Actual Result:

The report does not load.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7226131_1785903490272.Report_not_open.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7226131

Activity

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

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/60c1d4f7356259b1b4443d6e119a1d0ff792f898b068bcd7ecad7253287c851b

  3. melvin-bot commented on Aug 5, 2026

    @melvin-bot

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

  4. melvin-bot commented on Aug 5, 2026

    @melvin-bot

    @cristipaval @DylanDylann you have been assigned to this deploy blocker because you reviewed the offending PR: #97216

  5. melvin-bot commented on Aug 5, 2026

    @melvin-bot

    @iwiznia you have been assigned to this deploy blocker because you authored the offending PR: #97216

  6. melvin-bot commented on Aug 5, 2026

    @melvin-bot

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

  7. github-actions commented on Aug 5, 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.
  8. MelvinBot commented on Aug 5, 2026

    @MelvinBot
    Contributor

    🔍 Investigation Summary

    Classification: Frontend bug (fix lives in Expensify/App)
    Causing PR: #97216 - "Fix pdf secure link joining on mobile" by @iwiznia (High confidence this PR owns the flow; Medium-High on the exact failure mechanism)
    Related Issues / PRs: #96697 (issue #97216 was fixing), #94049 "Implement submit via PDF" (introduced the beta-gated feature)

    Recommendation: ROLL FORWARD

    #97216 is a legitimate, direct owner of this exact flow (not a coincidental QA attribution), but it is an incomplete fix rather than a fresh regression — reverting it would reintroduce the backgrounded-app / new-account cases it fixed. The clean fix is to persist the secure-link signal so it survives an app reload, which is smaller and safer than a revert.

    Assigned: @iwiznia (PR author), @cristipaval and @DylanDylann (approving reviewers) — already assigned to this issue by melvin-bot, which is correct here.
    Labels: No change. DeployBlockerCash is kept (an App PR contributed and the bug is not reproducible in production, so it cannot be removed). DeployBlocker (Web) was not present. Neither blocker label was removed.

    📋 Detailed Analysis

    Is #97216 actually the cause, or a coincidental QA attribution?

    It is genuinely the relevant PR, not a coincidence. #97216 is literally titled "Fix pdf secure link joining on mobile" and modifies exactly the Submit-via-PDF secure-link / report-loading-after-sign-in path described in the repro. It is included in the current StagingDeployCash for v9.4.50. The underlying feature was introduced earlier by #94049 (merged 2026-07-17) and is beta-gated — which is why this is not reproducible in production ("new feature, doesn't exist in prod", per #96697). So the flow is only exercised by internal/beta testers, and #97216 is the PR in this deploy that governs its behavior.

    Evidence / Root cause

    The distinctive repro step is step 5: "enable Use Staging Server" on the sign-in screen, mid-flow, then sign in with a new Gmail account. Toggling the server reloads the JS bundle. #97216 suppresses onboarding for secure-link visitors (so a new account lands on the shared report instead of onboarding) using a three-part signal:

    • src/hooks/useOnboardingFlow.ts L42-L44: getIsVisitingSecureLink() = hasSecureLinkKey(getCurrentUrl()) || hasSecureLinkKey(Navigation.getActiveRoute()) || hasSecureLinkKey(initialURL) —
      const {initialURL} = useInitialURLState();
      const getIsVisitingSecureLink = useCallback(() => hasSecureLinkKey(getCurrentUrl()) || hasSecureLinkKey(Navigation.getActiveRoute()) || hasSecureLinkKey(initialURL), [initialURL]);
      const isVisitingSecureLink = getIsVisitingSecureLink();
    • Used to skip onboarding at L77:
      if (getIsVisitingSecureLink()) {

    On native the first two terms are empty/not-yet-set (getCurrentUrl() returns empty on native; the report route is not active yet for a brand-new account still being routed), so the signal collapses to initialURL. But initialURL is volatile React state, not persisted:

    When "Use Staging Server" reloads the bundle, InitialURLContextProvider remounts and initialURL resets to null; the consumed deep link is not re-delivered by getInitialURL() on that reload. All three terms of getIsVisitingSecureLink() are now false, so onboarding is not suppressed and the brand-new Gmail account is routed into the onboarding flow instead of the shared report → "the report does not load".

    Why not production-impacting

    "Use Staging Server" is a QA/dev-only toggle; released production builds don't switch servers mid-sign-in, and the feature itself is beta-gated (absent from production). Real-world blast radius is limited to internal/beta testers hitting this specific reload sequence.

    Why ROLL FORWARD instead of REVERT

    Reverting #97216 restores the pre-fix behavior, where the secure-link signal was only !!currentUrl?.includes('secureKey=') — empty on native — so the new-account native cases it fixed would break again (a worse state). The targeted fix is to persist the secure-link signal across a reload (e.g. store secureKey / a "visiting secure link" flag in Onyx or session storage and read it there), so getIsVisitingSecureLink() survives the toggle-induced reload. Related code paths that rely on the same in-route signal:

    • Deep-link secure-link branch: src/libs/actions/Link.ts L519-L538 —
      if (Url.hasSecureLinkKey(route)) {
      Navigation.waitForProtectedRoutes().then(() => {
      // Secure links grant workspace + report access to a real account via JoinReportViaSecureLink, so an
      // anonymous session can never fulfill them even though report routes are otherwise anonymous-accessible
      // (canAnonymousUserAccessRoute would allow it). Force a real sign-in first; the deep link is re-processed
      // after sign-in. Without this the user lands on /r/:id?secureKey with no join, stuck loading/404.
      if (isAnonymousUser()) {
      signOutAndRedirectToSignIn(true);
      return;
      }
      // On cold launch the report is already the initial route; navigating again would stack a duplicate
      // that renders "not found" until the join grants access. Only navigate when we're not already there.
      if (Navigation.getTopmostReportId() === reportID) {
      return;
      }
      const secureKey = new URLSearchParams(route.split('?').at(1) ?? '').get('secureKey') ?? undefined;
      Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(reportID, undefined, undefined, undefined, secureKey), {waitForTransition: true});
      });
      return;
      }
    • Join + defer in report fetch: src/pages/inbox/ReportFetchHandler.tsx L162-L164 and L269-L275 —
      useEffect(() => {
      if (!secureKeyFromRoute || !reportIDFromRoute || isAnonymousUser || joinedSecureLinkReportIDRef.current === reportIDFromRoute) {
      return;
      }
      joinedSecureLinkReportIDRef.current = reportIDFromRoute;
      joinReportViaSecureLink(reportIDFromRoute, secureKeyFromRoute);
      }, [secureKeyFromRoute, reportIDFromRoute, isAnonymousUser]);

    Verification

  9. 7 remaining items

  10. iwiznia commented on Aug 5, 2026

    @iwiznia
    Contributor

    Not a blocker due to the reasons melvin said above.

  11. iwiznia commented on Aug 5, 2026

    @iwiznia
    Contributor

    @jponikarchuk can you reproduce this with a fresh PDF? As @DylanDylann said, the link is one time use.

  12. removed their assignment
    on Aug 5, 2026
  13. jponikarchuk commented on Aug 6, 2026

    @jponikarchuk

    @iwiznia Just to clarify, all tests were done using a fresh PDF.
    Issue is reproducible on Samsung S23FE/ Android 16 in v9.4.51-0.
    Use Staging Server should be enabled.

    Repro.1-97851.mp4
  14. changed the title [-]Submit via PDF-The report does not load[/-] [+][Submit] Submit via PDF-The report does not load[/+] on Aug 7, 2026
  15. iwiznia commented on Aug 7, 2026

    @iwiznia
    Contributor
    1. Does it only happen for new accounts?
    2. Is it only reproducible with a gmail account?
    3. Confused by the need of switching to the staging server, can it be reproduced in prod?
  16. IuliiaHerets commented on Aug 8, 2026

    @IuliiaHerets

    @iwiznia Yes, the issue is not reproducible for existing accounts.

    97851-1.mp4

    No, also reproducible with a private domain account without +.

    97851-2.mp4

    The issue is not reproducible in Prod now, but the behavior differs from that in Staging. The onboarding modal is displayed during the Prod test.

    97851-3.mp4

    The need to switch to the staging server is because:

    1. The toggle is defaulted to disabled after killing the app.
    2. All tests done by QA are run with the toggle enabled.
  17. iwiznia commented on Aug 10, 2026

    @iwiznia
    Contributor

    Given it is not happening in production, I am going to chalk it up to some config on the deep linking in staging and close this. Please report if it happens in production.

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

Metadata

Metadata

Labels

BugSomething 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