Skip to content

Resolve the container view before the unmount assertions read superview - #100016

Closed
mukhrr wants to merge 3 commits into
Expensify:mainfrom
mukhrr:fix/100008
Closed

mukhrr wants to merge 3 commits into
Expensify:mainfrom
mukhrr:fix/100008

Conversation

@mukhrr

@mukhrr mukhrr commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

-[RCTViewComponentView unmountChildComponentView:index:] asserts that the child being unmounted sits inside self.currentContainerView, but currentContainerView is not a pure getter. When _useCustomContainerView flips it creates or tears down _containerView and moves the existing subviews across, so reading it mutates the very hierarchy the assertion is inspecting. The order in which the two operands of == are evaluated is unspecified, so superview can be read before that migration runs and the check then compares a pre-migration superview against the post-migration container view. The tell is in the crash message: the reported existing parent tag equals the parent's own tag, meaning the child really is inside the parent, just not inside the parent's container view.

_useCustomContainerView is recomputed on every finalizeUpdates from styleWouldClipOverflowInk, so any view whose style crosses that threshold while it has mounted children is exposed. Bulk-duplicating reports mounts and unmounts enough of those at once to hit it, but the defect is not specific to that flow.

This adds react-native+0.86.0+042+fix-unmount-assert-container-view.patch, which resolves the container view into a local before the assertions read superview, so every operand comes from the same side of the migration. The [childComponentView removeFromSuperview] that follows was always correct, which is why this surfaced only as an abort and never as broken rendering. No app code changes.

Fixed Issues

$ #100008
PROPOSAL: #100008 (comment)

Tests

Precondition: an iOS build of this branch with assertions enabled, signed in to an account that has more than 15 reports containing 50+ expenses each.

  1. Open Search and go to the Reports tab.
  2. Select more than 15 of the prepared reports.
  3. Duplicate the selected reports.
  4. Verify the app stays open and does not abort with NSInternalInconsistencyException: Attempt to unmount a view which is mounted inside a different view.
  5. Verify a Copy of ... report appears for every report that was selected.
  • Verify that no errors appear in the JS console

Offline tests

This changes native view mounting only and has no network surface, so it cannot behave differently by connection state. To confirm no regression, run the Tests steps with the network turned off at step 2: the duplicates still appear optimistically and the app still does not abort. Turning the network back on syncs them as before.

QA Steps

Same as tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
642124834-de0fac1d-6aff-464f-af02-d6df9d295086.mp4
Android: mWeb Chrome
642124797-ebb1023b-6b39-4848-a334-2ad99b7ba344.mp4
iOS: Native
642124764-4e079a1e-937f-4e5b-b0a4-7bcefd538882.mp4
iOS: mWeb Safari
642124725-38906582-b61b-4565-985d-899fc28d36d7.mp4
MacOS: Chrome / Safari
641998971-d00da669-e0d7-4142-aea9-89042aea11f4.mp4

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

⚠️ This PR is possibly changing native code and/or updating libraries, it may cause problems with HybridApp. Please check if any patch updates are required in the HybridApp repo and run an AdHoc build to verify that HybridApp will not break. Ask Contributor Plus for help if you are not sure how to handle this. ⚠️

@mukhrr
mukhrr marked this pull request as ready for review September 1, 2026 10:52
@mukhrr
mukhrr requested a review from a team as a code owner September 1, 2026 10:52
@melvin-bot
melvin-bot Bot requested review from abzokhattab and removed request for a team September 1, 2026 10:52
@melvin-bot

melvin-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

@abzokhattab Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@mukhrr

mukhrr commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

@abzokhattab pls, ignore, @nkdengineer is going to review this. thanks

@abzokhattab

Copy link
Copy Markdown
Contributor

@MelvinBot can u remove me from reviewers and assign @nkdengineer instead

@MelvinBot
MelvinBot removed the request for review from abzokhattab September 2, 2026 22:04
@MelvinBot

Copy link
Copy Markdown
Contributor

Removed abzokhattab from the reviewers. I could not add nkdengineer — GitHub rejects it:

Reviews may only be requested from collaborators. One or more of the users or teams you specified is not a collaborator of the Expensify/App repository.

nkdengineer currently has no collaborator access on Expensify/App (GET /repos/Expensify/App/collaborators/nkdengineer → 404), so both the review request and the assignment are refused. Assigning them silently drops the user for the same reason — the PR is still assigned to mukhrr only.

For contrast, C+ reviewers who can be requested here (for example truph01) return 204 on that same collaborator check.

To finish this: someone with admin on Expensify/App needs to grant nkdengineer repo access (add them to the contributor team). Once that lands, reply @MelvinBot assign nkdengineer as reviewer on this PR and I'll set it.


view run

@abzokhattab

Copy link
Copy Markdown
Contributor

cc @luacmartins on the above #100016 (comment)

@luacmartins

Copy link
Copy Markdown
Contributor

@nkdengineer can you comment on this PR please?

@nkdengineer

Copy link
Copy Markdown
Contributor

@luacmartins I'm here

@luacmartins

Copy link
Copy Markdown
Contributor

Hmm GH isn't finding you. Maybe the comment below is accurate. Did your access change recently?

nkdengineer currently has no collaborator access on Expensify/App (GET /repos/Expensify/App/collaborators/nkdengineer → 404), so both the review request and the assignment are refused. Assigning them silently drops the user for the same reason — the PR is still assigned to mukhrr only.

@mukhrr

mukhrr commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

i think it's enough to assign @nkdengineer on issue and can review PR?

@nkdengineer

Copy link
Copy Markdown
Contributor

@mukhrr Please merge main.

@mukhrr

mukhrr commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

@nkdengineer done

@nkdengineer

Copy link
Copy Markdown
Contributor

@luacmartins Currently, I can only reproduce the crash after reverting this PR and have verified that the patch is the correct fix for this crash. Do we still want to continue applying this patch, or close it as it's no longer reproducible in production?

@luacmartins

Copy link
Copy Markdown
Contributor

Let's close it if the issues doesn't occur anymore. Before closing, I asked QA to retest it too. I'll close the issue if they can't reproduce it either

@mukhrr

mukhrr commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

closing per #100008 (comment). issue is not reproducible now

@mukhrr mukhrr closed this Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants