You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-07-16][$250] [Sentry: APP-6Z4] HybridApp iOS TypeError: this.fetchReport() undefined in ReportController.js #91397
this.fetchReport() is invoked from a lifecycle callback when the app becomes active, but this is undefined or the controller instance is not bound — so .then is called on undefined. Likely a lost this context in the become-active handler (missing .bind(this) / arrow function) or a race where the controller is torn down before the callback runs.
Reproduction
Unknown deterministically — Sentry shows it firing on app resume (performBecomeActiveStateCallback) across many iOS versions and app releases. See linked Sentry events for session context.
ReportController.js and fetchReport() are part of the YAPL JavaScript bundle that lives in the Mobile-Expensify submodule (Mobile-Expensify/app/), not in this repository. The YAPL native layer (-[YAPL performBecomeActiveStateCallback]) fires a callback into YAPL JS when the iOS app returns to the foreground — but at that point the ReportController instance's this context is undefined.
The most likely mechanism: in HybridApp mode, when the user transitions to NewDot, OldDot's JS context or controller instances get torn down — but the native iOS becomeActive observer registered by YAPL is not unregistered. When the app later resumes from background, the native observer fires into a deallocated or unbound JS controller, causing this.fetchReport() to throw because this is undefined.
Supporting evidence:
The crash is exclusive to iOS and hybrid_app platform — it does not occur on standalone NewDot or Android
It fires on app resume (performBecomeActiveStateCallback), not during normal navigation
It has persisted across many app versions (9.3.25 through 9.3.78), suggesting a structural lifecycle issue rather than a one-time regression
The HybridApp module's iOS stub in this repo is a no-op — the real native implementation (including becomeActive handling) lives in Mobile-Expensify
What changes do you think we should make in order to solve the problem?
Since the crash is in the Mobile-Expensify (OldDot/YAPL) codebase, the fix must be made there:
In Mobile-Expensify/app/ReportController.js (~line 1770): Add a guard before calling this.fetchReport() — e.g., if (!this) return; or check controller validity before invoking the method
In the YAPL native iOS layer (the class that registers performBecomeActiveStateCallback): Ensure the native becomeActive observer is removed when the HybridApp transitions the user to NewDot, so stale callbacks don't fire into a torn-down JS context
Alternatively, bind the callback with an arrow function or .bind(this) when registering it, so the this reference is captured at registration time rather than relying on the instance being alive at invocation time
Option 2 (unregistering the observer on transition) is the most robust fix, as it addresses the root cause rather than masking it with a null guard.
What alternative solutions did you explore? (Optional)
A null guard on this (option 1) is simpler but only masks the symptom — the native observer would still fire unnecessarily after the OldDot context is torn down, which could cause other subtle issues. The proper fix is to clean up the native lifecycle observer when it's no longer needed.
Related issues
Expensify/App#89090 — iOS crash on soft-killing the app (potentially related lifecycle issue)
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.
When the iOS HybridApp resumes from background, -[YAPL performBecomeActiveStateCallback] fires and invokes a JS callback that calls this.fetchReport().then(...) inside ReportController.js around line 1770. At that point this is either undefined (strict-mode class method passed as a plain callback without binding) or the controller instance has already been torn down, so this.fetchReport is undefined and calling .then on undefined throws a fatal TypeError bridged to native as an nsexception.
What changes do you think we should make in order to solve the problem?
Two fixes are needed: bind the method correctly and guard against a destroyed instance.
1. Bind the become-active handler (or convert to arrow function):
This prevents the fatal crash even if the controller is partially torn down before the resume callback fires (e.g., navigation away mid-session).
3. Unregister the become-active listener on controller teardown:
Ensure the listener is removed in whatever destroy/unmount lifecycle the controller exposes, so a stale callback can never fire after this is gone.
What alternative solutions did you explore?
I considered wrapping the entire callback in a try/catch to swallow the error, but that only hides the symptom. The correct fix is eliminating the lost-this context at the source and cleaning up the listener on teardown.
changed the title [-][Sentry: APP-6Z4] HybridApp iOS TypeError: this.fetchReport() undefined in ReportController.js[/-][+][$250] [Sentry: APP-6Z4] HybridApp iOS TypeError: this.fetchReport() undefined in ReportController.js[/+]on May 22, 2026
Activity
MelvinBot commentedon May 22, 2026
Proposal
What is the root cause of that problem?
The crash occurs in OldDot (YAPL) code, not in the NewDot App repo. The stack trace shows:
ReportController.jsandfetchReport()are part of the YAPL JavaScript bundle that lives in the Mobile-Expensify submodule (Mobile-Expensify/app/), not in this repository. The YAPL native layer (-[YAPL performBecomeActiveStateCallback]) fires a callback into YAPL JS when the iOS app returns to the foreground — but at that point theReportControllerinstance'sthiscontext isundefined.The most likely mechanism: in HybridApp mode, when the user transitions to NewDot, OldDot's JS context or controller instances get torn down — but the native iOS
becomeActiveobserver registered by YAPL is not unregistered. When the app later resumes from background, the native observer fires into a deallocated or unbound JS controller, causingthis.fetchReport()to throw becausethisisundefined.Supporting evidence:
iOSandhybrid_appplatform — it does not occur on standalone NewDot or AndroidperformBecomeActiveStateCallback), not during normal navigationWhat changes do you think we should make in order to solve the problem?
Since the crash is in the Mobile-Expensify (OldDot/YAPL) codebase, the fix must be made there:
Mobile-Expensify/app/ReportController.js(~line 1770): Add a guard before callingthis.fetchReport()— e.g.,if (!this) return;or check controller validity before invoking the methodperformBecomeActiveStateCallback): Ensure the nativebecomeActiveobserver is removed when the HybridApp transitions the user to NewDot, so stale callbacks don't fire into a torn-down JS context.bind(this)when registering it, so thethisreference is captured at registration time rather than relying on the instance being alive at invocation timeOption 2 (unregistering the observer on transition) is the most robust fix, as it addresses the root cause rather than masking it with a null guard.
What alternative solutions did you explore? (Optional)
A null guard on
this(option 1) is simpler but only masks the symptom — the native observer would still fire unnecessarily after the OldDot context is torn down, which could cause other subtle issues. The proper fix is to clean up the native lifecycle observer when it's no longer needed.Related issues
Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.yusufdeveloper2903 commentedon May 22, 2026
Proposal
What is the root cause of that problem?
When the iOS HybridApp resumes from background,
-[YAPL performBecomeActiveStateCallback]fires and invokes a JS callback that callsthis.fetchReport().then(...)insideReportController.jsaround line 1770. At that pointthisis eitherundefined(strict-mode class method passed as a plain callback without binding) or the controller instance has already been torn down, sothis.fetchReportisundefinedand calling.thenonundefinedthrows a fatalTypeErrorbridged to native as annsexception.What changes do you think we should make in order to solve the problem?
Two fixes are needed: bind the method correctly and guard against a destroyed instance.
1. Bind the become-active handler (or convert to arrow function):
Using an arrow function captures
thislexically so it's never lost when the callback is handed off to the native bridge.2. Add a null-guard before calling
.then:This prevents the fatal crash even if the controller is partially torn down before the resume callback fires (e.g., navigation away mid-session).
3. Unregister the become-active listener on controller teardown:
Ensure the listener is removed in whatever destroy/unmount lifecycle the controller exposes, so a stale callback can never fire after
thisis gone.What alternative solutions did you explore?
I considered wrapping the entire callback in a
try/catchto swallow the error, but that only hides the symptom. The correct fix is eliminating the lost-thiscontext at the source and cleaning up the listener on teardown.KJ21-ENG commentedon May 22, 2026
🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.
melvin-bot commentedon May 22, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @thesahindia (
External)[-][Sentry: APP-6Z4] HybridApp iOS TypeError: this.fetchReport() undefined in ReportController.js[/-][+][$250] [Sentry: APP-6Z4] HybridApp iOS TypeError: this.fetchReport() undefined in ReportController.js[/+]melvin-bot commentedon May 22, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022057737583305255963
85 remaining items
[-][Due for payment 2026-07-16] [$250] [Sentry: APP-6Z4] HybridApp iOS TypeError: this.fetchReport() undefined in ReportController.js[/-][+][Due for payment 2026-07-16][$250] [Sentry: APP-6Z4] HybridApp iOS TypeError: this.fetchReport() undefined in ReportController.js[/+]melvin-bot commentedon Jul 16, 2026
Payment Summary
Upwork Job
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Jul 17, 2026
Payment Summary
Contributor: @gijoe0295 due $250 via NewDot
Contributor+: @Krishna2323 due $250 via NewDot
Is the above correct? I see a mention about of their being two PRs.
gijoe0295 commentedon Jul 18, 2026
Yes that's correct. We need 2 PRs to completely fix the Sentry crash but I don't think it's worth increasing compensation
JmillsExpensify commentedon Jul 18, 2026
$250 approved for @gijoe0295
melvin-bot commentedon Jul 21, 2026
@mallenexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
gijoe0295 commentedon Jul 22, 2026
@mallenexpensify Can you close this?
laurenreidexpensify commentedon Jul 24, 2026
$250 approved for @Krishna2323