Repository navigation
Description
Sentry
- https://expensify.sentry.io/issues/APP-7AR —
IllegalStateException: addViewAt: failed to insert view into parent - https://expensify.sentry.io/issues/APP-H7A —
IllegalStateException: Unable to remove a view from a view that is not a ViewGroup
Both are Fabric mount-item failures on the Android HybridApp, filed together because they share the same root cause: a mount instruction is applied to a view tree that no longer matches the shadow tree it was computed against.
Impact (snapshot at filing, 2026-08-17)
| Sentry ID | Users (last 14d) | Users (total since first seen) | Events | First seen |
|---|---|---|---|---|
| APP-7AR | 63 | 86 | 132 | 2026-03-11 |
| APP-H7A | 25 | 29 | 29 | 2026-07-07 |
- Last seen: ongoing (both fired within the last hour at filing time)
- Platform: Android, HybridApp (
org.me.mobiexpensifyg) - App version(s): 9.4.52-11, 9.4.53-x, 9.4.54-1
- Affected view(s):
TabNavigator,Inbox - Mechanism:
chained/UncaughtExceptionHandler, levelfatal - Devices: not device-specific — reproduced on Samsung SM-S942B (Android 16) and SM-F936B (Android 14), across
device.class: high
Stack trace (top frames)
APP-7AR — insert path
com.facebook.react.fabric.FabricUIManager$DispatchUIFrameCallback.doFrameGuarded(FabricUIManager.java:1664)
com.facebook.react.fabric.mounting.MountItemDispatcher.dispatchMountItems(MountItemDispatcher.kt:250)
com.facebook.react.fabric.mounting.mountitems.IntBufferBatchMountItem.execute(IntBufferBatchMountItem.kt:122)
com.facebook.react.fabric.mounting.SurfaceMountingManager.addViewAt(SurfaceMountingManager.kt:382)
com.facebook.react.views.view.ReactClippingViewManager.addView(ReactClippingViewManager.kt:36)
android.view.ViewGroup.addViewInner(ViewGroup.java:5648)
android.view.ViewGroup.addInArray(ViewGroup.java:5767)
Underlying throw: IndexOutOfBoundsException: index=1 count=0, rethrown by SurfaceMountingManager.addViewAt:390 as IllegalStateException: addViewAt: failed to insert view [N] into parent [M] at index 1.
APP-H7A — remove path
com.facebook.react.fabric.FabricUIManager$DispatchUIFrameCallback.doFrameGuarded(FabricUIManager.java:1568)
com.facebook.react.fabric.mounting.MountItemDispatcher.dispatchMountItems(MountItemDispatcher.kt:246)
com.facebook.react.fabric.mounting.mountitems.IntBufferBatchMountItem.execute(IntBufferBatchMountItem.kt:125)
com.facebook.react.fabric.mounting.SurfaceMountingManager.removeViewAt(SurfaceMountingManager.kt:415)
Throw: IllegalStateException: Unable to remove a view from a view that is not a ViewGroup. ParentTag: N - Tag: M - Index: K.
Suspected cause
Fabric applies a batch of mount items against a native view hierarchy that has already diverged from the shadow tree the batch was computed against. The insert case lands in ReactClippingViewManager, so the removeClippedSubviews path is the strongest lead — clipped children are added and removed outside the normal mount sequence, which lets the parent's real child count fall out of step with the index Fabric asks for. The remove case fails the same way from the other direction: the recorded parent tag no longer resolves to a ViewGroup.
Worth checking whether either regressed with the RN 0.85/0.86 upgrade. APP-H7A first appeared 2026-07-07, which is close to that work.
Reproduction
Unknown. Both are fatal and low-frequency per user (roughly one event per affected user), which is consistent with a timing-dependent mount race rather than a deterministic screen. See the Sentry events for device and navigation context.
Starting points:
- Exercise fast navigation in and out of
TabNavigator/Inboxon Android while list content is still streaming in. - Look for components in that path that set
removeClippedSubviewsand also mutate children asynchronously.
Related
- Sibling Sentry IDs: APP-7AR and APP-H7A (both covered by this issue)
- Parent tracker: [Tracking] Top Sentry crashes monthly check-in #91302
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022089426048073704405
- Upwork Job ID: 2089426048073704405
- Last Price Increase: 2026-08-18
Issue Owner
Current Issue Owner: @mallenexpensifyMetadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
melvin-bot commentedon Aug 17, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @linhvovan29546 (
External)melvin-bot commentedon Aug 17, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022089426048073704405
MelvinBot commentedon Aug 17, 2026
Proposal
What is the root cause of that problem?
The Inbox/LHN report list passes
removeClippedSubviewsto a FlashList v2 (@shopify/flash-list2.3.0) atLHNOptionsList.tsx:179. This is the only virtualized list in theTabNavigator→Inboxchain, which matches the affected views on both Sentry crashes exactly.FlashList v2 is a pure-JS recycler and does not consume
removeClippedSubviews— the prop falls through its...restand is spread onto the underlying RNScrollView. On Android that activatesReactClippingViewManager, which adds and removes clipped children outside the normal Fabric mount sequence. When Fabric later applies a batch of mount items (IntBufferBatchMountItem→SurfaceMountingManager.addViewAt/removeViewAt), the parent's real child count/tree has already diverged from the shadow tree the batch was computed against, so:IndexOutOfBoundsException: index=1 count=0→ rethrown asaddViewAt: failed to insert view into parent— lands inReactClippingViewManager.addView, confirming the clipping path.ViewGroup→Unable to remove a view from a view that is not a ViewGroup.Because FlashList v2 already does its own view recycling,
removeClippedSubviewshere is redundant and harmful — it double-manages the same children that Fabric is also mounting/unmounting, which is the timing-dependent race described in the issue. The same anti-pattern is repeated on the Search-tab FlashLists (BaseSearchList/index.native.tsx:46,SearchStaticList.tsx:382).What changes do you think we should make in order to solve the problem?
Remove
removeClippedSubviewsfrom the FlashList v2 instances (or gate it tofalseon Android). Primary fix atLHNOptionsList.tsx:179; apply the same treatment to the Search FlashLists so the crash can't resurface there. FlashList v2 recycles views itself, so dropping the prop is functionally a no-op for scrolling perf while eliminating the RN clipping path the crash originates from. The codebase already treats this prop as risky and disables it explicitly elsewhere (e.g.removeClippedSubviews={false}inBaseAutoCompleteSuggestions.tsx).What alternative solutions did you explore? (Optional)
A native-side guard in
ReactClippingViewManager/SurfaceMountingManagerwould be more general but is stock RN 0.86.0 code — App does not patchReactClippingViewManager, and there is already an iOS-only recycle-safety patch (react-native+0.86.0+032, which resets_removeClippedSubviews = NOon recycle) with no Android equivalent. A patch there is higher-risk and broader than needed given the JS-side prop is the direct trigger.Investigation details & evidence
Chain to the list:
TabNavigator.native.tsx→REPORTS_SPLIT_NAVIGATOR→ReportsSplitNavigator(sidebar =SCREENS.INBOX) →SidebarLinks.tsx:110<LHNOptionsList>→ FlashList atLHNOptionsList.tsx:179. The bottom tab bar itself contains no virtualized list, so the "default-true on Android" concern doesn't apply there — this list sets the prop explicitly.Prop leak: In
@shopify/flash-list@2.3.0,dist/recyclerview/RecyclerView.jsdestructures props without extractingremoveClippedSubviews(it lands in...rest) and spreads...restonto the internal RNScrollView— so the prop reaches the native AndroidReactClippingViewManagerpath from the crash stack.Crash signature nuance: Both are fatal native
IllegalStateException/IndexOutOfBoundsthrows fromViewGroup.addView/removeView, i.e. a genuine tree/index divergence — distinct from the soft-logged missing-viewStatehandling that RN 0.86.0 upstreamed foraddViewAt/removeViewAt(see App patch+038details.md). So this is a real mount-ordering race, not a missing-viewState blank screen.RN-upgrade timeline (the issue's regression suspicion): RN went
0.83.1 → 0.85.3(PR #92484, merged 2026-07-09) →0.86.0(PR #96372, merged 2026-08-10). APP-H7A first-seen 2026-07-07 is ~2 days before 0.85.3 merged tomain, but PR #92484 was open from 2026-06-03, so early events likely came from 0.85.3 ad-hoc/test builds. Whether the FlashList-v2 +removeClippedSubviewscombination (or the RN bump) is what tipped it should be confirmed by bucketing APP-7AR/APP-H7A events by app version in Sentry. Note the current App HEAD (ca6b99d) is a revert of PR #96772 — worth checking whether that PR touched LHN/FlashList clipping.Low-risk validation: ship
removeClippedSubviews={false}on Android atLHNOptionsList.tsx:179(or behind a small experiment) and watch APP-7AR/APP-H7A stop.Related issues
[Sentry: APP-3E3]HybridApp Android FabricgetViewStateRetryableMountingLayerException) — same HybridApp Android Fabric-mount family; may share this root cause.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/98791)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
linhvovan29546 commentedon Aug 18, 2026
🆘 C+ Help Wanted
abbasifaizan70 commentedon Aug 18, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Android HybridApp, the Fabric renderer is fatally crashing while mounting/unmounting rows in the Inbox (LHN) list, inside the
TabNavigatorstack. Two related native crashes are reported in Sentry:IllegalStateException: addViewAt: failed to insert view into parent— thrown fromReactClippingViewManager.addViewwhen the underlyingIndexOutOfBoundsException: index=1 count=0occurs (Fabric asks to insert a child at index 1 into a nativeViewGroupthat currently has 0 real children attached).IllegalStateException: Unable to remove a view from a view that is not a ViewGroup— thrown fromSurfaceMountingManager.removeViewAtwhen the parent tag Fabric recorded no longer resolves to an actualViewGroup.Both are timing-dependent (roughly one crash per affected user) and both bottom out in
ReactClippingViewManager, which is the native view manager that only gets exercised when a scrollable container is rendered withremoveClippedSubviews.What is the root cause of that problem?
The Inbox list (
LHNOptionsList) renders itsFlashListwithremoveClippedSubviewsenabled:App/src/components/LHNOptionsList/LHNOptionsList.tsx
Lines 162 to 180 in 12b0038
removeClippedSubviewsis a legacyView/ScrollViewoptimization: on Android it turns the scroll content's container into aReactClippingViewGroup, whose native code independently tracks all logical children versus the subset that is currently attached to the realViewGroup(children outside the clipping rect are physically detached). Crucially, this attach/detach bookkeeping is driven by scroll-position recalculations on the UI thread and is not part of Fabric's serialized mount-item queue — it mutates the same native child array that Fabric'sSurfaceMountingManager.addViewAt/removeViewAtalso mutate when applying the next batch of mount instructions.@shopify/flash-list(package.jsonpins2.3.0) does its own item virtualization/recycling (a bounded pool of cell views repositioned as the user scrolls, further limited here bydrawDistance={250}), so this prop is simply spread through to FlashList's internalCompatScrollView— it isn't something FlashList implements or needs; it just re-enables the same RN-core clipping code path that any classicScrollView/FlatListwould get. Layering that independent, UI-thread-driven clipping mutation on top of FlashList's own recycling gives two systems (Fabric mounting + native clipping) uncoordinated write access to the same view hierarchy. When fast navigation in/out of theInbox/TabNavigatorroute interleaves a Fabric mount batch (adding/removing LHN rows asreports/reportAttributesstream in from Onyx) with a clipping recalculation triggered by the same scroll/layout pass, the two can disagree about the container's actual child count or about whether a given tag is still a liveViewGroup:addViewAtis issued for an index beyond what's really attached →IndexOutOfBoundsException/addViewAtfailure (APP-7AR).removeViewAtfor that stale tag fails because the tag no longer resolves to aViewGroup(APP-H7A).This matches the issue's own "suspected cause" and the stack traces exactly (
ReactClippingViewManager.addViewin the insert path). It's also consistent with community reports againstflash-listwhere disablingremoveClippedSubviewsresolves otherwise-unexplained view-state/rendering bugs — the prop is a known-unsafe combination with FlashList's recycling model, and this codebase already avoids it elsewhere for exactly that class of risk (the mention list'sFlatListexplicitly hardcodes it off):App/src/components/AutoCompleteSuggestions/BaseAutoCompleteSuggestions.tsx
Lines 112 to 122 in 12b0038
What changes do you think we should make in order to solve the problem?
Remove
removeClippedSubviewsfrom the Inbox list'sFlashList, the same wayBaseAutoCompleteSuggestionsImplalready opts out of it on its list:App/src/components/LHNOptionsList/LHNOptionsList.tsx
Line 179 in 12b0038
(i.e. delete the
removeClippedSubviewsline entirely —FlashListalready virtualizes rows via its own recycler anddrawDistance, so no replacement prop is needed.)This is the minimal, best-practice fix because:
removeClippedSubviewslist, so it's consistent with existing conventions rather than introducing a new one.FlashListstill bounds the number of rendered/recycled rows via its own virtualization plus the existingdrawDistance={250}, so scroll performance for the LHN — which was the only reasonremoveClippedSubviewswould have been added — is unaffected.Edge cases:
ReactClippingViewGroup/ReactClippingViewManagercode path entirely for this list, eliminating the race between Fabric's mount-item queue and native clip-driven attach/detach — directly addressing both APP-7AR and APP-H7A.removeClippedSubviewsis implemented differently there and isn't implicated by either stack trace; removing it is still safe since FlashList's own recycling already provides the virtualization benefit.react-native-web, so there is no behavior change to verify there.reports/reportAttributesare fetched or rendered, only how the scroll container manages its native children, so optimistic updates and offline queueing are unaffected.removeClippedSubviewsis set directly on theFlashListinsideLHNOptionsList, not exposed viaLHNOptionsListProps, so no caller ofLHNOptionsListis affected by this change.Inbox/TabNavigator(the reported repro pattern) should be specifically retested on a physical/emulated Android device with new-architecture enabled, since that's the timing-dependent condition that surfaced the crash.mukhrr commentedon Aug 18, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-08-18 13:56:07 UTC.
Proposal
What is the root cause of that problem?
I opened the actual
@shopify/flash-list@2.3.0package this app ships and traced whereremoveClippedSubviewsgoes once it leavesLHNOptionsList.App/src/components/LHNOptionsList/LHNOptionsList.tsx
Lines 162 to 180 in c7b8272
LHNOptionsListpasses a bareremoveClippedSubviews(sotrue) straight into<FlashList>.RecyclerView.jsin@shopify/flash-list@2.3.0destructures a long list of known props but never touchesremoveClippedSubviews, so it falls into the leftover...restobject....restontoCompatScrollView, which resolves toAnimated.ScrollView, React Native's ownScrollView, not anything FlashList manages itself.ScrollView.jsforwardsremoveClippedSubviewsstraight ontoNativeScrollContentView, and on Android that is exactlyReactClippingViewManager, the class named in the APP-7AR stack trace.LHNOptionsListin a Jest harness with the platform mocked toandroidand queried the actual host node bytestID="lhn-options-list": on current code itsremoveClippedSubviewsprop resolves totrueon the realRCTScrollViewhost, not just on the<FlashList>JSX, so the leak is observable in the rendered tree, not only in the library source.ViewHolderCollectionanddrawDistance={250}, so turning on native clipping on top of that makes two systems add and remove the same child views on different schedules, one through Fabric's mount batches and one through the classic RN clipping pass outside them. That is what lets a parent's real child count fall out of step with the index a mount batch was computed against, matching both the insert (index=1 count=0) and remove (parent tag no longer a ViewGroup) failures.I also checked the RN-upgrade theory the issue itself raises. The flash-list v1 to v2 migration landed 2025-09-09, about six months before APP-7AR's first-seen date of 2026-03-11, so the leak has been present since that migration and isn't new. Whatever shifted the timing odds around March wasn't the FlashList version bump, and I didn't chase that further since it isn't needed to fix the crash.
What changes do you think we should make in order to solve the problem?
I disabled
removeClippedSubviewson Android only, sinceplatformis already computed at module scope in this file:drawDistance={250} - removeClippedSubviews + removeClippedSubviews={platform !== CONST.PLATFORM.ANDROID}App/src/CONST/index.ts
Lines 1059 to 1064 in c7b8272
With this change the same Jest harness shows the host
RCTScrollViewnode'sremoveClippedSubviewsresolving tofalseon Android. I added a regression test,tests/ui/components/LHNOptionsListRemoveClippedSubviewsTest.tsx, that reads that prop off the real scroll host rather than off the<FlashList>element; it fails against currentmain(receivestrue) and passes with this change.What alternative solutions did you explore? (Optional)
I considered dropping
removeClippedSubviewson every platform and widening the fix to the Search tab's FlashLists, since they set the same prop. I kept the change Android-only and scoped toLHNOptionsListinstead: withplatform !== CONST.PLATFORM.ANDROID, the value on iOS and web staystrue, identical to what ships today, so there's no regression surface off Android. Sentry's own "Affected view(s)" for both issues names onlyTabNavigatorandInbox, so I didn't touch the Search lists without a crash report pointing at them.I also considered catching the
addViewAt/removeViewAtexceptions inSurfaceMountingManagerinstead, but that would leave the native and shadow trees diverged and could drop the rest of the mount transaction or render stale content. Removing the clipping path that causes the divergence is the smaller, root-cause fix.The codebase already avoids this same prop on a different asynchronously changing list:
App/src/components/AutoCompleteSuggestions/BaseAutoCompleteSuggestions.tsx
Lines 112 to 121 in c7b8272
And RN 0.86.0's own patch notes confirm the nullable-state guards for
addViewAt/removeViewAtonly cover a missing view state, not a parent whose child tree has diverged, which is why they can't mask this crash:App/patches/react-native/details.md
Lines 326 to 332 in c7b8272
Abdulloh0109 commentedon Aug 18, 2026
🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.
136 remaining items
mallenexpensify commentedon Oct 5, 2026
@MelvinBot @samranahm was hired for this job in Upwork, how and why?
oqildev commentedon Oct 5, 2026
@mallenexpensify
Yes. I accepted the job.
MelvinBot commentedon Oct 5, 2026
samranahmwas never selected for this job. The Upwork hire came from the profile linkSARAMALI15792gave you. The Upwork account behind that link appears to be the one you see assamranahm.Timeline
samranahmposted a proposal. ProposalPolice withdrew it as a duplicate. No one selected it.SARAMALI15792was assigned. They said the Upwork job returned a 403 and shared this profile: https://www.upwork.com/freelancers/~012263396cc08bc99c (comment).SARAMALI15792registered the same Upwork profile ID with the email saramali15792@gmail.com (comment).I can't see Upwork, so I can't confirm who owns that profile. If it shows as
samranahm, check whether the two GitHub accounts share one Upwork account.Their PR, Fix Fabric mounting-transaction merge order picking oldest instead of newest pending transaction (APP-7AR), was closed. The C+ later chose
oqildev's proposal. You can likely end that contract without payment.view run
samranahm commentedon Oct 5, 2026
@mallenexpensify It's not me, it was @SARAMALI15792 #98791 (comment), we previously decided to go with @SARAMALI15792's proposal but later changed to @oqildev
linhvovan29546 commentedon Oct 5, 2026
@mallenexpensify Sorry, I forgot about this. It’s complete now.
mallenexpensify commentedon Oct 5, 2026
@oqildev paid, leaving open for further review
mountiny commentedon Oct 7, 2026
(Vit's agent) Agreed, APP-H7A is a separate issue. It now has its own tracker: [Sentry: APP-H7A] Fabric removeViewAt crashes removing view from non-ViewGroup parent.
ViewGroup. APP-H7A throws when the parent tag has aViewStatewhose view is null or not aViewGroup(SurfaceMountingManager.ktat v0.86.0).addViewAt.addViewAt.Next steps:
twisterdotcom commentedon Oct 12, 2026
$250 approved for @linhvovan29546 in Report ID: R00MmIpK5TXj.
Zapier Logs
Run ID: 00040eee-d6ba-a271-bb7e-6ef8d7fe38f4SO: https://stackoverflowteams.com/c/expensify/questions/7582
linhvovan29546 commentedon Oct 13, 2026
I think this is good to close