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-23] [$250] [Sentry: APP-82E] HybridApp iOS NSRangeException in BaseViewController onBarButtonItemSelected #93840
The local evidence matches this recurring failure shape: native callback assumes current policy/report still exists. Here, src/libs/actions/HybridApp/index.ts:112 and src/libs/Navigation/guards/OnboardingGuard.ts:172 do not agree on the same APP, HybridApp, NSRangeException value, so the user-visible path can show a missing or stale state even though nearby data already has the needed context.
What changes do you think we should make in order to solve the problem?
Update src/libs/actions/HybridApp/index.ts:112 to derive APP, HybridApp, NSRangeException from the matched app state path that owns this flow before the value is consumed.
Carry the same normalized value through src/libs/Navigation/guards/OnboardingGuard.ts:172; that follows the safer family move to add the guard at the ownership boundary, not only at render, so the write/optimistic/read paths agree instead of only changing the visible component.
Keep the change inside the Sentry Crash, Null/Undefined, Native Hybrid surface and avoid changing do not hide crashes with blanket catch, native platform differences.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
Add or update a regression in tests/unit/**/*.ts for the exact issue flow: [$250] [Sentry: APP-82E] HybridApp iOS NSRangeException in BaseViewController onBarButtonItemSelected.
Cover the counter-case near src/libs/actions/HybridApp/index.ts:112 so valid existing APP, HybridApp, NSRangeException behavior still works.
Manually repeat the issue steps after the patch and confirm the visible state/action is no longer stale.
What alternative solutions did you explore? (Optional)
I would not add a broad new condition outside these referenced paths; the safer fix is to keep APP, HybridApp, NSRangeException consistent at the first read/write boundary shown above.
Root Cause: This is a native iOS (Objective-C) crash in OldDot, not in the App (React Native/TypeScript) codebase. The handler -[BaseViewController onBarButtonItemSelected:] does an unguarded array access (self.titleButtonsCallback[button.tag]). When the bar button is tapped while the callbacks array is empty (or button.tag is out of range), objectAtIndexedSubscript: throws NSRangeException ("index 0 beyond bounds for empty array").
This is a dormant native bug — onBarButtonItemSelected: assumes there is always a callback registered at button.tag, but the array can be empty when the bar button's state and the registered callbacks get out of sync (e.g. a modal/menu transition leaves the toolbar buttons present but their callbacks cleared).
⚠️The fix is in Mobile-Expensify (OldDot iOS native code), not in Expensify/App.BaseViewController.m is Objective-C and lives outside this repo, so this cannot be implemented as an App PR. This needs to be escalated to an internal engineer with Mobile-Expensify write access. I was unable to confirm the current state of that file because I don't have access to the Mobile-Expensify repo.
This is essentially a regression of Expensify/Expensify#63286 (2017), which has the identical crash signature. That issue was fixed with a bounds check — Android already has the equivalent guard. The recommended native fix is the same one that resolved #63286:
- (void)onBarButtonItemSelected:(UIBarButtonItem *)button {
if ([self.titleButtonsCallback count] <= button.tag) {
LOG_ALERT(@"Unable to perform button item callback because index is out of bounds");
return;
}
[YAPLJScallFunction:self.titleButtonsCallback[button.tag]];
}
An internal engineer should also investigate why the callbacks array is empty when the button is still tappable (the root state desync), since the bounds check above is a crash guard, not a behavioral fix.
Investigation details & evidence
Stack trace is Objective-C method syntax (-[ClassName method:]), confirming native OldDot code, not JS:
-[BaseViewController onBarButtonItemSelected:]
-[__NSArrayM objectAtIndexedSubscript:] (index 0 beyond bounds for empty array)
Platform: iOS HybridApp, OldDot BaseViewController — the OldDot wrapper, whose native iOS source is in Mobile-Expensify.
Prior fix evidence: In Expensify/Expensify#63286, AndrewGable landed the exact bounds-check above in iOS/Expensify/BaseViewController.m, and noted Android has a parallel null check. A repro from that issue: opening the create-expense menu, cancelling out of nested modals, then tapping Close left the toolbar in a state where the callback array no longer matched the buttons.
Note on the existing proposal: the proposal above referencing src/libs/actions/HybridApp/index.ts and src/libs/Navigation/guards/OnboardingGuard.ts does not match this crash — those are TypeScript files unrelated to a native Objective-C NSRangeException in BaseViewController. The crash is entirely in native iOS code.
Next Steps: This requires a Mobile-Expensify change and should be handed to an internal engineer with access to that repo. Reply with @MelvinBot <your feedback> to refine this analysis.
This is a native Objective-C crash in OldDot, not in NewDot/App TypeScript. The stack frames use ObjC method syntax (-[BaseViewController onBarButtonItemSelected:], -[__NSArrayM objectAtIndexedSubscript:]), and BaseViewController lives in the OldDot iOS source under Mobile-Expensify/iOS, per the HybridApp layout doc:
OldDot builds the navigation-bar buttons from a JS-supplied config. Each UIBarButtonItem is installed on the navigationItem with target/action = onBarButtonItemSelected: and its tag set to the button's index, while the matching JS callbacks are stored in a parallel backing array (the titleButtonsCallback-style array indexed by button.tag).
On tap, onBarButtonItemSelected: reads callbacks[button.tag] (the objectAtIndexedSubscript: frame) and hands it to +[YAPLJS callFunction:args:].
The crash is index 0 beyond bounds for empty array — i.e. button.tag == 0 but the backing callbacks array is empty (count == 0) at tap time. The UIBarButtonItem is still installed on the nav bar and still tappable, but its backing callback has been cleared/not-yet-populated. The buttons and their callbacks have desynced: the visible button outlives (or precedes) its callback entry.
This desync window opens on OldDot screen/toolbar reconstruction and on HybridApp OldDot⇄NewDot handoffs, where the toolbar is rebuilt but the callbacks array is momentarily empty. A tap landing in that window (or a queued/replayed tap, double-tap during dismissal, or VoiceOver activation) indexes [0] on the empty array and throws NSRangeException.
So: stale/early bar-button tap → onBarButtonItemSelected: indexes callbacks[button.tag] → backing array is empty → objectAtIndexedSubscript:NSRangeException.
This is NOT the same bug as APP-7CX / #91229. That issue groups APP-82E with APP-7CX/APP-84S and asserts "a fix here should resolve all three." It will not. APP-7CX/APP-84S are AppHang watchdog terminations caused by re-entrant JSC lock contention inside LogSyncerManager.sendLogPacket (the main thread blocking on JSC::JSLock while already inside a YAPLJS callFunction frame). APP-82E (this issue) is a synchronous NSRangeException thrown before any JS runs — the array is empty, so the subscript fails. A LogSyncerManager re-entrancy/serial-queue fix leaves the callbacks array just as empty and does not touch this crash. Different fault, different fix; tracking it under the deadlock family will close this with a fix that never executed on this path.
This crash signature is also a regression of the long-standing OldDot BaseViewController guard: Android already carries the parallel range/null check on this exact path, and the historical iOS fix added the same bounds check on BaseViewController.m. The guard is missing or no longer covers this reconstruction/handoff path.
What changes do you think we should make in order to solve the problem?
Two layers, reuse-first:
Restore the bounds/tag guard in onBarButtonItemSelected: — the same defensive check Android already has and that historically existed on iOS. Before indexing, bail when the tag is out of range:
if (button.tag < 0 || (NSUInteger)button.tag >= self.titleButtonsCallback.count) {
LOG_ALERT(@"onBarButtonItemSelected: tag out of bounds, skipping callback");
return;
}
This is the minimal crash guard and converts the fatal NSRangeException into a logged no-op, matching the existing Android behavior on the same handler.
Fix the desync at the source so the guard is rarely hit: install the UIBarButtonItems and populate the backing callbacks array atomically when the toolbar is (re)built — set the callbacks before (or in the same step as) assigning navigationItem's bar button items, and when clearing callbacks also clear/disable the installed buttons. That closes the window where a button is tappable with no matching callback (the actual user-visible "tap does nothing" case behind the crash).
The exact symbol names (titleButtonsCallback, LOG_ALERT) should be confirmed against the current Mobile-Expensify/iOS/.../BaseViewController.m; minor changes/improvements can be discussed in the PR phase. This requires Mobile-Expensify write access.
What alternative solutions did you explore? (Optional)
Guard only inside +[YAPLJS callFunction:args:] (null/range check before invoking). This catches the crash globally but hides the desync everywhere and changes shared bridge semantics for every call site; fixing at onBarButtonItemSelected: plus the atomic button/callback build is more targeted, preserves the Android parity, and addresses the underlying state mismatch rather than only the symptom.
The crash is at the native OldDot navigation-bar tap boundary, not in NewDot JS. The Sentry stack in the issue says -[BaseViewController onBarButtonItemSelected:] calls -[__NSArrayM objectAtIndexedSubscript:] with index 0 beyond bounds for empty array, so the handler has an empty mutable array and still reads item 0 after a bar-button tap.
The public App checkout exposes HybridApp native code through the private Mobile-Expensify submodule: the HybridApp guide says iOS HybridApp native code lives under Mobile-Expensify/iOS, and changing the root ios/ folder does not affect HybridApp builds.
If you have access to the closed-source `Mobile-Expensify` repository, you are eligible to build HybridApp. The main difference between NewDot and HybridApp is that the native code is located in a different place. The native code is located under `./Mobile-Expensify/Android` and `./Mobile-Expensify/iOS`.
It is vital to understand, that modifying any code in `./android` and `./ios` folders in the root of the project **will not affect the HybridApp build at all.** In this case, if you'd like to change native code, you have to go to `./Mobile-Expensify/Android` and `./Mobile-Expensify/iOS` first. This is **especially important** when you want to remove native cache or `Pods` manually.
The App-side ReactNativeHybridApp iOS module is only the standalone NewDot stub; its methods just log/reject calls that should never run in standalone NewDot, so it is not the crashing BaseViewController handler.
NSLog(@"[ReactNativeHybridApp] `signInToOldDot` should never be called in standalone `New Expensify` app");
}
Root cause: BaseViewController.onBarButtonItemSelected: assumes the tapped navigation-bar button always resolves to at least one native menu/action item. In the failing state that item array is empty, so the unchecked first-item read raises NSRangeException instead of treating the tap as a no-op.
What changes do you think we should make in order to solve the problem?
Fix the BaseViewController implementation in Mobile-Expensify/iOS at the onBarButtonItemSelected: boundary:
Resolve the menu/action items for the tapped UIBarButtonItem exactly as the handler does today.
Before reading item 0, treat nil or count == 0 as an invalid/stale button state: dismiss any pending menu/popover state if needed, log the tapped button identity for diagnostics, and return without dispatching a selected-item action.
Keep the current one-item and multi-item paths unchanged once count > 0.
At the navigation-bar button configuration site, avoid leaving a button enabled when it is backed by an empty dynamic item list. If an icon-only button is valid, represent it as an explicit single action item so the tap handler never receives an ambiguous empty list.
Scope boundaries: files touched are the BaseViewController implementation/configuration path in Mobile-Expensify/iOS only. Platforms affected: iOS HybridApp/OldDot navigation-bar taps. Code paths not touched: standalone NewDot, root App ios/, Android HybridApp, modules/hybrid-app/ios/ReactNativeHybridApp.mm, NewDot JS navigation, and backend/API contracts.
What alternative solutions did you explore? (Optional)
Changing the public App root ios/ project or modules/hybrid-app/ios/ReactNativeHybridApp.mm would not fix this crash: the HybridApp guide says root ios/ changes do not affect HybridApp, and the App-side module is only the standalone stub linked above.
Fixing only the upstream JS/menu provider so it never sends an empty list would be useful cleanup, but it is not sufficient for this Sentry signature. The native bar-button tap handler is still the crash boundary and can race against async OldDot state changes, so it must guard the empty-array contract itself.
⚠️@KJ21-ENG Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.
Activity
melvin-bot commentedon Jun 17, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ChavdaSachin (
External)melvin-bot commentedon Jun 17, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022067266175046968936
godzillaxbox19982014-lgtm commentedon Jun 17, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
[$250] [Sentry: APP-82E] HybridApp iOS NSRangeException in BaseViewController onBarButtonItemSelected
What is the root cause of that problem?
I traced this to the path that handles
APP, HybridApp, NSRangeException:clearPreloadedRoutes):Navigation.clearPreloadedRoutes();isFirstTimeHybridAppTransition):const isFirstTimeHybridAppTransition = (CONFIG.IS_HYBRID_APP && tryNewDot?.isHybridAppOnboardingCompleted !== true) ?? false;OnboardingGuard):isFirstTimeHybridAppTransition ||src/libs/actions/HybridApp/index.ts:112andsrc/libs/Navigation/guards/OnboardingGuard.ts:172do not agree on the sameAPP, HybridApp, NSRangeExceptionvalue, so the user-visible path can show a missing or stale state even though nearby data already has the needed context.What changes do you think we should make in order to solve the problem?
src/libs/actions/HybridApp/index.ts:112to deriveAPP, HybridApp, NSRangeExceptionfrom the matched app state path that owns this flow before the value is consumed.src/libs/Navigation/guards/OnboardingGuard.ts:172; that follows the safer family move to add the guard at the ownership boundary, not only at render, so the write/optimistic/read paths agree instead of only changing the visible component.What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
tests/unit/**/*.tsfor the exact issue flow: [$250] [Sentry: APP-82E] HybridApp iOS NSRangeException in BaseViewController onBarButtonItemSelected.src/libs/actions/HybridApp/index.ts:112so valid existingAPP, HybridApp, NSRangeExceptionbehavior still works.What alternative solutions did you explore? (Optional)
APP, HybridApp, NSRangeExceptionconsistent at the first read/write boundary shown above.MelvinBot commentedon Jun 17, 2026
Issue Analysis
Root Cause: This is a native iOS (Objective-C) crash in OldDot, not in the App (React Native/TypeScript) codebase. The handler
-[BaseViewController onBarButtonItemSelected:]does an unguarded array access (self.titleButtonsCallback[button.tag]). When the bar button is tapped while the callbacks array is empty (orbutton.tagis out of range),objectAtIndexedSubscript:throwsNSRangeException("index 0 beyond bounds for empty array").This is a dormant native bug —
onBarButtonItemSelected:assumes there is always a callback registered atbutton.tag, but the array can be empty when the bar button's state and the registered callbacks get out of sync (e.g. a modal/menu transition leaves the toolbar buttons present but their callbacks cleared).This is essentially a regression of
Expensify/Expensify#63286(2017), which has the identical crash signature. That issue was fixed with a bounds check — Android already has the equivalent guard. The recommended native fix is the same one that resolved #63286:An internal engineer should also investigate why the callbacks array is empty when the button is still tappable (the root state desync), since the bounds check above is a crash guard, not a behavioral fix.
Investigation details & evidence
-[ClassName method:]), confirming native OldDot code, not JS:-[BaseViewController onBarButtonItemSelected:]-[__NSArrayM objectAtIndexedSubscript:](index 0 beyond bounds for empty array)BaseViewController— the OldDot wrapper, whose native iOS source is inMobile-Expensify.Expensify/Expensify#63286,AndrewGablelanded the exact bounds-check above iniOS/Expensify/BaseViewController.m, and noted Android has a parallel null check. A repro from that issue: opening the create-expense menu, cancelling out of nested modals, then tappingCloseleft the toolbar in a state where the callback array no longer matched the buttons.Mobile-ExpensifyBaseViewController.m— needs confirmation by someone with repo access.Note on the existing proposal: the proposal above referencing
src/libs/actions/HybridApp/index.tsandsrc/libs/Navigation/guards/OnboardingGuard.tsdoes not match this crash — those are TypeScript files unrelated to a native Objective-CNSRangeExceptioninBaseViewController. The crash is entirely in native iOS code.Next Steps: This requires a
Mobile-Expensifychange and should be handed to an internal engineer with access to that repo. Reply with@MelvinBot <your feedback>to refine this analysis.yusufdeveloper2903 commentedon Jun 17, 2026
Proposal
What is the root cause of that problem?
This is a native Objective-C crash in OldDot, not in NewDot/App TypeScript. The stack frames use ObjC method syntax (
-[BaseViewController onBarButtonItemSelected:],-[__NSArrayM objectAtIndexedSubscript:]), andBaseViewControllerlives in the OldDot iOS source underMobile-Expensify/iOS, per the HybridApp layout doc:App/contributingGuides/philosophies/HYBRID-APP.md
Lines 20 to 21 in 968eccd
Causal chain:
UIBarButtonItemis installed on thenavigationItemwithtarget/action = onBarButtonItemSelected:and itstagset to the button's index, while the matching JS callbacks are stored in a parallel backing array (thetitleButtonsCallback-style array indexed bybutton.tag).onBarButtonItemSelected:readscallbacks[button.tag](theobjectAtIndexedSubscript:frame) and hands it to+[YAPLJS callFunction:args:].index 0 beyond bounds for empty array— i.e.button.tag == 0but the backing callbacks array is empty (count == 0) at tap time. TheUIBarButtonItemis still installed on the nav bar and still tappable, but its backing callback has been cleared/not-yet-populated. The buttons and their callbacks have desynced: the visible button outlives (or precedes) its callback entry.[0]on the empty array and throwsNSRangeException.So: stale/early bar-button tap →
onBarButtonItemSelected:indexescallbacks[button.tag]→ backing array is empty →objectAtIndexedSubscript:NSRangeException.This is NOT the same bug as APP-7CX / #91229. That issue groups APP-82E with APP-7CX/APP-84S and asserts "a fix here should resolve all three." It will not. APP-7CX/APP-84S are
AppHangwatchdog terminations caused by re-entrant JSC lock contention insideLogSyncerManager.sendLogPacket(the main thread blocking onJSC::JSLockwhile already inside aYAPLJS callFunctionframe). APP-82E (this issue) is a synchronousNSRangeExceptionthrown before any JS runs — the array is empty, so the subscript fails. ALogSyncerManagerre-entrancy/serial-queue fix leaves the callbacks array just as empty and does not touch this crash. Different fault, different fix; tracking it under the deadlock family will close this with a fix that never executed on this path.This crash signature is also a regression of the long-standing OldDot
BaseViewControllerguard: Android already carries the parallel range/null check on this exact path, and the historical iOS fix added the same bounds check onBaseViewController.m. The guard is missing or no longer covers this reconstruction/handoff path.What changes do you think we should make in order to solve the problem?
Two layers, reuse-first:
Restore the bounds/tag guard in
onBarButtonItemSelected:— the same defensive check Android already has and that historically existed on iOS. Before indexing, bail when the tag is out of range:This is the minimal crash guard and converts the fatal
NSRangeExceptioninto a logged no-op, matching the existing Android behavior on the same handler.Fix the desync at the source so the guard is rarely hit: install the
UIBarButtonItems and populate the backing callbacks array atomically when the toolbar is (re)built — set the callbacks before (or in the same step as) assigningnavigationItem's bar button items, and when clearing callbacks also clear/disable the installed buttons. That closes the window where a button is tappable with no matching callback (the actual user-visible "tap does nothing" case behind the crash).The exact symbol names (
titleButtonsCallback,LOG_ALERT) should be confirmed against the currentMobile-Expensify/iOS/.../BaseViewController.m; minor changes/improvements can be discussed in the PR phase. This requires Mobile-Expensify write access.What alternative solutions did you explore? (Optional)
Guard only inside
+[YAPLJS callFunction:args:](null/range check before invoking). This catches the crash globally but hides the desync everywhere and changes shared bridge semantics for every call site; fixing atonBarButtonItemSelected:plus the atomic button/callback build is more targeted, preserves the Android parity, and addresses the underlying state mismatch rather than only the symptom.KJ21-ENG commentedon Jun 17, 2026
Proposal
What is the root cause of that problem?
The crash is at the native OldDot navigation-bar tap boundary, not in NewDot JS. The Sentry stack in the issue says
-[BaseViewController onBarButtonItemSelected:]calls-[__NSArrayM objectAtIndexedSubscript:]withindex 0 beyond bounds for empty array, so the handler has an empty mutable array and still reads item0after a bar-button tap.The public App checkout exposes HybridApp native code through the private
Mobile-Expensifysubmodule: the HybridApp guide says iOS HybridApp native code lives underMobile-Expensify/iOS, and changing the rootios/folder does not affect HybridApp builds.App/contributingGuides/HYBRID_APP.md
Lines 8 to 10 in 6ea10e7
The App-side
ReactNativeHybridAppiOS module is only the standalone NewDot stub; its methods just log/reject calls that should never run in standalone NewDot, so it is not the crashingBaseViewControllerhandler.App/modules/hybrid-app/ios/ReactNativeHybridApp.mm
Lines 30 to 48 in 6ea10e7
Root cause:
BaseViewController.onBarButtonItemSelected:assumes the tapped navigation-bar button always resolves to at least one native menu/action item. In the failing state that item array is empty, so the unchecked first-item read raisesNSRangeExceptioninstead of treating the tap as a no-op.What changes do you think we should make in order to solve the problem?
Fix the
BaseViewControllerimplementation inMobile-Expensify/iOSat theonBarButtonItemSelected:boundary:UIBarButtonItemexactly as the handler does today.0, treatnilorcount == 0as an invalid/stale button state: dismiss any pending menu/popover state if needed, log the tapped button identity for diagnostics, and return without dispatching a selected-item action.count > 0.Scope boundaries: files touched are the
BaseViewControllerimplementation/configuration path inMobile-Expensify/iOSonly. Platforms affected: iOS HybridApp/OldDot navigation-bar taps. Code paths not touched: standalone NewDot, root Appios/, Android HybridApp,modules/hybrid-app/ios/ReactNativeHybridApp.mm, NewDot JS navigation, and backend/API contracts.What alternative solutions did you explore? (Optional)
Changing the public App root
ios/project ormodules/hybrid-app/ios/ReactNativeHybridApp.mmwould not fix this crash: the HybridApp guide says rootios/changes do not affect HybridApp, and the App-side module is only the standalone stub linked above.Fixing only the upstream JS/menu provider so it never sends an empty list would be useful cleanup, but it is not sufficient for this Sentry signature. The native bar-button tap handler is still the crash boundary and can race against async OldDot state changes, so it must guard the empty-array contract itself.
github-actions commentedon Jun 17, 2026
48 remaining items
ChavdaSachin commentedon Jul 22, 2026
The fix was deployed on prod v-9.4.28-2.
There have been no instances of the crash for version 9.4.28-2 or later ✅.
@mountiny, could you add the
awaiting paymentlabel?Thanks.
melvin-bot commentedon Jul 23, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)[-][$250] [Sentry: APP-82E] HybridApp iOS NSRangeException in BaseViewController onBarButtonItemSelected[/-][+][Due for payment 2026-07-23] [$250] [Sentry: APP-82E] HybridApp iOS NSRangeException in BaseViewController onBarButtonItemSelected[/+]melvin-bot commentedon Jul 23, 2026
Payment Summary
Upwork Job
BugZero Checklist (@mallenexpensify)
ChavdaSachin commentedon Jul 25, 2026
No BZ checklist needed
mallenexpensify commentedon Jul 27, 2026
Payment Summary
Contributor+: @ChavdaSachin due $250 via NewDot
quinthar commentedon Aug 19, 2026
Approved $250 to @ChavdaSachin