Skip to content

[Due for payment 2026-08-30] [$250] [Sentry: APP-2WT] HybridApp Android OldDot crash — Didn't get a policy in expensify.js #96176

Closed

Description

@mountiny

Sentry

https://expensify.sentry.io/issues/APP-2WT

Impact (snapshot at filing)

  • Users (total since first seen): 123
  • Events: 1,498
  • Users (last 14d): 29
  • First seen: 2025-12-16
  • Last seen: now (ongoing)
  • Platform: Android HybridApp (OldDot)
  • App version(s): 9.4.25 through 9.4.31
  • Affected route(s): unknown (auth/policy load during app init)
  • Mechanism: chained (JSCException / RuntimeException)

Stack trace (top frames, first-party only)

app/expensify.js (policy response handler)
app/libs/api.js (_oldResponseHandler)
app/libs/network.js
yapl.android.Yapl.callJSFunction
yapl.android.Yapl.handleJSException

Suspected cause

OldDot throws Crashing. Didn't get a policy when the auth response handler cannot resolve policy data despite a successful HTTP 200 response.

Reproduction

Unknown — see Sentry events linked from the Sentry issue.

Related

  • Sibling Sentry IDs (if any): APP-75M (iOS variant, tracked separately in App#92414)
  • Prior GH issues: none
Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. self-assigned this
    on Jul 20, 2026
  2. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jul 20, 2026
  3. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 20, 2026
  4. melvin-bot commented on Jul 20, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @rojiphil (External)

  5. samranahm commented on Jul 20, 2026

    @samranahm
    Contributor

    Proposal

    What is the root cause of that problem?

    On Android HybridApp, NewDot completes authentication and then hands control to OldDot. That handoff is driven from HybridApp.ts in signInToOldDotAndChooseExperience, which signs the user into OldDot and asks it to pick which experience to render:

    function signInToOldDotAndChooseExperience(

    Once OldDot takes over, its own _oldResponseHandler in expensify.js fetches the account/policy payload. The Sentry stack shows OldDot receiving a successful HTTP 200 but with no usable policy in the response, so OldDot throws Crashing. Didn't get a policy and the JS exception bubbles up through yapl.android.Yapl.handleJSException.

    The trigger from the NewDot side is timing: after NewDot marks the auth screens ready via setReadyToShowAuthScreens in HybridApp/index.ts, the sign-in transition can be started before the HybridApp session state is fully hydrated:

    function setReadyToShowAuthScreens(readyToShowAuthScreens: boolean) {
    // This value is only relevant for HybridApp, so we can skip it in other environments.

    When the OldDot sign-in is initiated while the HybridApp Onyx state (useNewDotSignInPage and related fields) is still transitional, OldDot proceeds to request policy for an account whose policy list has not yet propagated, receives an empty-but-successful response, and crashes.

    /** State and configuration of a HybridApp */
    type HybridApp = {
    /** Stores the information if HybridApp uses NewDot's sign-in flow */
    useNewDotSignInPage?: boolean;

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

    1. In HybridApp.ts, guard signInToOldDotAndChooseExperience so the OldDot sign-in transition is only fired after the HybridApp session state is confirmed hydrated, avoiding the race where OldDot fetches policy against a not-yet-propagated account.

    function signInToOldDotAndChooseExperience(

    function signInToOldDotAndChooseExperience(...) {
        if (!hybridApp?.readyToShowAuthScreens) {
            return;
        }
        // existing sign-in + choose-experience handoff
    }
    1. In HybridApp/index.ts, only call the OldDot handoff once setReadyToShowAuthScreens(true) has been committed, so the readiness flag and the sign-in transition cannot interleave.

    function setReadyToShowAuthScreens(readyToShowAuthScreens: boolean) {
    // This value is only relevant for HybridApp, so we can skip it in other environments.

    This keeps NewDot from pushing OldDot into its policy fetch before the account is ready, which is the condition that produces the empty policy 200 and the crash.

    1. Because the throw itself lives in OldDot expensify.js, file a paired OldDot change so the policy response handler treats a 200 with no policy as a recoverable retry instead of a hard Crashing. Didn't get a policy exception, mirroring the iOS variant tracked in App#92414. This is the durable fix for the remaining events that are not caused by the handoff race.

    What alternative solutions did you explore? (Optional)

    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.

  6. changed the title [-][Sentry: APP-2WT] HybridApp Android OldDot crash — Didn't get a policy in expensify.js[/-] [+][$250] [Sentry: APP-2WT] HybridApp Android OldDot crash — Didn't get a policy in expensify.js[/+] on Jul 20, 2026
  7. melvin-bot commented on Jul 20, 2026

    @melvin-bot
  8. yuvrajangadsingh commented on Jul 20, 2026

    @yuvrajangadsingh
    Contributor

    Proposal

    Re-state problem

    Android HybridApp users are hitting a hard OldDot crash "Crashing. Didn't get a policy" during the NewDot→OldDot handoff, with 123 users / ~1.5k events since Dec 2025. It happens after a successful 200 response, meaning OldDot's _oldResponseHandler in expensify.js gets a policy request response back but can't find a policy in it.

    Root cause

    signInToOldDotAndChooseExperience in src/libs/HybridApp.ts is what kicks off the OldDot sign-in and tells OldDot which policy to select:

    HybridAppModule.signInToOldDot({
        autoGeneratedLogin: credentials.autoGeneratedLogin,
        autoGeneratedPassword: credentials.autoGeneratedPassword,
        authToken: session.authToken,
        email: getCurrentUserEmail() ?? '',
        // eslint-disable-next-line rulesdir/no-default-id-values
        policyID: activePolicyID ?? '',
        signingInWithSAML: hybridApp?.signingInWithSAML ?? false,
    });

    src/libs/HybridApp.ts:108-116

    activePolicyID comes from ONYXKEYS.NVP_ACTIVE_POLICY_ID (src/libs/HybridApp.ts:66-72) and is populated separately/async from the sign-in gating checks at src/libs/HybridApp.ts:85-105. Those gating checks verify session, credentials, and 2FA state, but never check that activePolicyID has actually loaded. Note the eslint-disable-next-line rulesdir/no-default-id-values right above the fallback — someone already had to explicitly bypass our own lint rule against faking an ID with an empty string default, which is a strong signal this was a known shortcut, not a safe default.

    So on a fresh sign-in where the NVP hasn't propagated to Onyx yet (or the user genuinely has no active policy set), we call signInToOldDot with policyID: ''. OldDot takes that empty string, gets back a 200 on its account/policy fetch, but has nothing to select against it, and throws Crashing. Didn't get a policy in expensify.js's response handler instead of treating "no policy id" as "let me pick one myself."

    Changes to make

    This is a bug, so the fix should be the smallest thing that stops sending a bogus policy id, not a rearchitecture of the handoff:

    1. In src/libs/HybridApp.ts:108-116, don't send policyID: '' as a stand-in for "no policy yet." Either:
      • omit policyID from the payload entirely when activePolicyID is undefined (if the native module/OldDot treats a missing key as "let OldDot pick"), or
      • gate the signInToOldDot call so it waits for activePolicyID to resolve (even to explicitly-empty/none) before firing, same way the function already waits on credentials and 2FA fields at src/libs/HybridApp.ts:98.
    2. Since the actual throw lives in OldDot's expensify.js response handler (Mobile-Expensify submodule, not in this repo), pair this with a defensive fix there so a missing/empty policy on a 200 response falls back to a normal "select first policy" flow instead of a hard crash. That's the durable fix for any other path that can produce the same empty policyID case, and mirrors how the iOS twin (APP-75M / App#92414) is being tracked.

    Alternatives

    There's a human proposal already open on this issue that frames it as a hydration timing race and proposes gating on hybridApp?.readyToShowAuthScreens before firing the OldDot handoff. I don't think that's the actual trigger, readyToShowAuthScreens is set after this call by design (src/libs/actions/HybridApp/index.ts:129-135), so gating on it would create a chicken-and-egg deadlock rather than fix the crash. The eslint-disable comment right next to the activePolicyID ?? '' fallback is the more concrete smoking gun here, that's a self-flagged shortcut, not a race condition. I'd rather fix what's actually being sent over the bridge than add a readiness gate that doesn't touch the value causing the crash.

    working branch with the fix applied: diff

  9. Hi-im-Connect commented on Jul 20, 2026

    @Hi-im-Connect

    Proposal

    What is the root cause of that problem?

    The crash has two layers — a bad input produced in this repo, and a hard throw in OldDot.

    NewDot (this repo). signInToOldDotAndChooseExperience in src/libs/HybridApp.ts is retriggered by five Onyx connections (hybridApp, tryNewDot, credentials, session, account), and its readiness guards check all five — but never the active policy. activePolicyID comes from a sixth connection that only caches the value and does not retrigger the function:

    let activePolicyID: OnyxEntry<string>;
    Onyx.connectWithoutView({
    key: ONYXKEYS.NVP_ACTIVE_POLICY_ID,
    callback: (newActivePolicyID) => {
    activePolicyID = newActivePolicyID;
    },
    });

    On a fresh sign-in, session/credentials/account arrive straight from the sign-in responses, while nvp_expensify_activePolicyID only arrives later with OpenApp data. So the handoff routinely fires while the NVP is still undefined and sends policyID: '' — a fallback the code itself flags by suppressing the rulesdir/no-default-id-values lint rule:

    App/src/libs/HybridApp.ts

    Lines 108 to 116 in 6a1f1a3

    HybridAppModule.signInToOldDot({
    autoGeneratedLogin: credentials.autoGeneratedLogin,
    autoGeneratedPassword: credentials.autoGeneratedPassword,
    authToken: session.authToken,
    email: getCurrentUserEmail() ?? '',
    // eslint-disable-next-line rulesdir/no-default-id-values
    policyID: activePolicyID ?? '',
    signingInWithSAML: hybridApp?.signingInWithSAML ?? false,
    });

    OldDot (Mobile-Expensify submodule). OldDot signs in, then its policy bootstrap (_oldResponseHandler → the policy response handler in expensify.js, per the Sentry stack) gets an HTTP 200 whose payload contains no policy it can resolve against the empty ID, and throws Crashing. Didn't get a policy, which Android surfaces as a fatal crash through Yapl.handleJSException.

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

    1. In src/libs/HybridApp.ts, make the NVP_ACTIVE_POLICY_ID connection retrigger signInToOldDotAndChooseExperience, the same way the other five connections do. Without this, any "wait for the policy" gate would wait forever — nothing currently re-runs the function when the NVP arrives.

    2. Add a guard so the handoff only fires once the active-policy state is known: either activePolicyID is set, or the initial app data load has completed (ONYXKEYS.HAS_LOADED_APP), which means the user genuinely has no active policy — in that case we hand off without inventing one and let OldDot use its own default policy selection. Distinguishing "not loaded yet" from "legitimately none" is what keeps policy-less users (e.g. fresh accounts) from being deadlocked out of OldDot.

    3. Pair this with a small Mobile-Expensify (submodule) change: in the expensify.js policy response handler, treat a 200 with no resolvable policy as recoverable — fall back to OldDot's default policy selection instead of the hard Crashing. Didn't get a policy throw. This covers any residual server-side path that returns an empty policy set.

    Result: NewDot stops sending a fabricated empty policyID during the race window, and OldDot no longer hard-crashes on the remaining empty-policy cases.

    What alternative solutions did you explore? (Optional)

    • Gating the handoff on readyToShowAuthScreens: circular — that flag is set by this same function after signInToOldDot fires, so the gate would deadlock the sign-in.
    • Gating only on activePolicyID being truthy: deadlocks users who genuinely have no active policy NVP, and does nothing unless the NVP connection also retriggers the function (today it doesn't).
    • OldDot-only defensive fix: stops the crash but during the race users would still land in OldDot without their active workspace preselected; the NewDot timing fix is what removes the bad input at the source.
  10. melvin-bot commented on Jul 20, 2026

    @melvin-bot

    📣 @Hi-im-Connect! 📣
    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:

    1. Make sure you've read and understood the contributing guidelines.
    2. 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.
    3. 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.
    4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
      Screen Shot 2022-11-16 at 4 42 54 PM
      Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
    
  11. 42 remaining items

  12. mountiny commented on Aug 30, 2026

    @mountiny
    ContributorAuthor

    last one I see is 55 so yeah I think we are good

  13. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed
    ReviewingHas a PR in review
    on Aug 30, 2026
  14. changed the title [-][$250] [Sentry: APP-2WT] HybridApp Android OldDot crash — Didn't get a policy in expensify.js[/-] [+][Due for payment 2026-08-30] [$250] [Sentry: APP-2WT] HybridApp Android OldDot crash — Didn't get a policy in expensify.js[/+] on Aug 30, 2026
  15. melvin-bot commented on Aug 30, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  16. melvin-bot commented on Aug 30, 2026

    @melvin-bot

    Payment Summary

    • Reviewer: @rojiphil owed $250 via NewDot
    • Contributor: @fedirjh does not require payment (Contractor)

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  17. rojiphil commented on Aug 31, 2026

    @rojiphil
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: Not Required. The existing checklist is good enough to capture such issues.

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    Regression Test Proposal Template

    Regression Test Proposal

    Precondition:

    1. This test is applicable only for native hybrid apps
    2. The Hybrid app account must be using OldDot and not NewDot

    Test:

    1. In Classic OldDot, enable domain 2FA enforcement by signing in as a domain admin
    2. Sign-in in hybrid app as the user of the domain
    3. Verify that the hybrid app continues with 2FA authentication flow
    4. Verify that the OldDot does not crash with Didn't get a policy

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-a923-a575-825a-e4399fdf2c34
  18. mallenexpensify commented on Sep 1, 2026

    @mallenexpensify
    Contributor

    @MelvinBot we updated the payment summary to include a link to the associated PR. I don't see it above. Why is it missing? If something needs updating, can you review https://github.com/Expensify/Expensify/issues/676523 then add details to there?

  19. mallenexpensify commented on Sep 1, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @rojiphil due $250 via NewDot

  20. MelvinBot commented on Sep 1, 2026

    @MelvinBot
    Contributor

    The PR link is missing because the fix for this issue landed in a different repo. The Resolving PRs: line is built by matching Expensify/App PRs that name the issue in their ### Fixed Issues section. This one was fixed by https://github.com/Expensify/Mobile-Expensify/pull/14059, so the lookup found nothing and the whole block was dropped silently.

    This is a different cause than the one already tracked, so I've added the details there — https://github.com/Expensify/Expensify/issues/676523 now covers both, along with a proposed fix that would catch this case.

    Evidence

    The suggested fix on that issue: when the lookup comes back empty, fall back to scanning the issue's comments for any github.com/Expensify/*/pull/<n> URL and list those. That would have surfaced PR 14059 here.

    One thing I couldn't check: I don't have read access to Mobile-Expensify, so I can't confirm whether PR 14059 links back to this issue in its ### Fixed Issues section. That detail changes which of two fixes is the right one, and I noted it on the tracking issue for someone with access to check.


    view run

  21. quinthar commented on Sep 2, 2026

    @quinthar
    Contributor

    Approved $250 to @rojiphil

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 productionExternalAdded to denote the issue can be worked on by a contributorWeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions