Skip to content

[$175] [Sentry: APP-JKQ] Web: BaseGenericTooltip loops into "Maximum update depth exceeded" in Search expense report rows #105707

Open

Description

@mountiny

Sentry

https://expensify.sentry.io/issues/APP-JKQ

Impact (snapshot at filing)

  • Users (total since first seen): 34
  • Events: 39
  • Users (last 14d, production 9.5.25 to 9.5.27): 17 (9.5.25: 7, 9.5.26: 7, 9.5.27: 3)
  • First seen: 2026-07-30
  • Last seen: 2026-11-03 (ongoing)
  • Platform: web (standalone)
  • App version(s): 9.5.25 to 9.5.27 in the scan window
  • Affected route(s) (parameterized): /r/:reportID, with the Search expense report list mounted
  • Mechanism: generic (React error boundary), level fatal, app blocking

Stack trace (top frames, first-party only)

Error: Maximum update depth exceeded (React #185)
  react-dom commitHookEffectListMount -> layout effect create() -> dispatchSetState

Component stack, innermost first:
  BaseGenericTooltip               src/components/Tooltip/BaseGenericTooltip/index.tsx
  Tooltip_GenericTooltip
  ExpenseReportListItemRowWide
  ExpenseReportListItemRow
  AvatarTooltipsProvider
  ExpenseReportListItem
  SearchList_BaseSearchList
  Search_ExpenseReportSearchView

Sentry shows UpdateRequiredView/index.tsx:78 as the most relevant frame. That frame looks like a source map mismatch, so the component stack above is the reliable signal.

Suspected cause

BaseGenericTooltip measures its content in a mount useLayoutEffect and then calls setContentMeasuredWidth and setWrapperMeasuredHeight (src/components/Tooltip/BaseGenericTooltip/index.tsx:69 on main). The effect has empty dependencies, so the loop means the tooltip remounts on each update inside the Search expense report rows. Needs investigation, starting with what remounts the tooltip in ExpenseReportListItemRowWide.

Reproduction

Unknown. See the Sentry events linked from the Sentry issue. The crash happens while the Search expense report list renders a row tooltip.

Related

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @gijoe0295

Activity

  1. self-assigned this
    on Nov 3, 2026
  2. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Nov 3, 2026
  3. melvin-bot commented on Nov 3, 2026

    @melvin-bot

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

  4. changed the title [-][Sentry: APP-JKQ] Web: BaseGenericTooltip loops into "Maximum update depth exceeded" in Search expense report rows[/-] [+][$175] [Sentry: APP-JKQ] Web: BaseGenericTooltip loops into "Maximum update depth exceeded" in Search expense report rows[/+] on Nov 3, 2026
  5. melvin-bot commented on Nov 3, 2026

    @melvin-bot
  6. MelvinBot commented on Nov 3, 2026

    @MelvinBot
    Contributor

    Proposal

    Confidence: medium on why the tooltip gets blamed. Low on what drives the loop: I couldn't open the Sentry events (the Sentry connection failed), and I don't have a reproduction yet.

    What is the root cause of that problem?

    BaseGenericTooltip is where React throws, but it isn't what causes the loop. Its layout effect has empty dependencies and runs once per mount (BaseGenericTooltip/index.tsx:69-83), so it can't loop by itself. It shows up in the stack because it remounts on every commit of a loop that something else starts:

    1. Hovering a cell in the row sets isRendered = true in GenericTooltip. Hiding the tooltip never sets it back to false, so the hidden tooltip stays mounted (GenericTooltip.tsx:95-97, 164-177).
    2. The tooltip's key includes text (GenericTooltip.tsx:194-212). FlashList reuses row components for other items and keeps their state, so a reused row gets new text while isRendered is still true. The tooltip then remounts in that same commit and its mount effect calls setState again.
    3. Something keeps re-laying out the Search list in sync layout effects. My best guess is FlashList's web layout loop, which the repo has already patched twice for React Add link styles for sidebar footer #185 (patches/@shopify/flash-list/details.md). Each pass reassigns rows, so the tooltip remounts each time. Child layout effects run first, so when the nested update count passes 50, the tooltip's setState is the one that throws.

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

    1. In GenericTooltip, stop keeping a hidden tooltip mounted when its key changes. Compute the key once. If it changes while isVisible is false, set isRendered back to false during render. This stops reused rows from remounting tooltips, and it removes BaseGenericTooltip from the loop.
    2. Before you merge, reproduce the case and check whether the crash just moves to a new top frame, such as FlashList setRenderId. To reproduce: open /r/:reportID with the Search expense report list next to the RHP, use classic (non-overlay) scrollbars, hover a cell, then resize the RHP or window. If the crash moves, the FlashList measurement loop needs its own fix. Check whether the recently merged Fix report table header is larger than rest of the table (FlashList patch 017) already covers it.

    What alternative solutions did you explore? (Optional)

    • Add guards to the BaseGenericTooltip effect (for example, skip the update when values are equal). Rejected: every fresh mount starts at undefined, so a guard never skips anything.
    • Reset isRendered when the hide animation ends. This works too, but it's blunter. Every hover would remount the tooltip.
    • Render BaseGenericTooltip only while isVisible is true. Rejected: it cuts off the hide animation.
    Investigation details

    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/105707) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.


    view run

  7. camesenin commented on Nov 3, 2026

    @camesenin
  8. melvin-bot commented on Nov 3, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  9. kevinjosh10 commented on Nov 3, 2026

    @kevinjosh10

    Proposal

    What is the root cause of that problem?

    The crash is caused by a cyclic remount-and-measure loop between GenericTooltip, BaseGenericTooltip, and FlashList row recycling:

    1. Persistent isRendered in GenericTooltip:
      In src/components/Tooltip/GenericTooltip.tsx:95-97, hovering a cell calls showTooltip, which sets setIsRendered(true) and setIsVisible(true).
      When the tooltip is hidden in hideTooltip (GenericTooltip.tsx:146-158), setIsVisible(false) is set, but isRendered is never reset to false. It remains permanently true.

    2. Aggressive Key-Based Remounting on Recycled Rows:
      In GenericTooltip.tsx:175-194:

      {shouldRender && isRendered && (
          <BaseGenericTooltip
              ...
              key={[text, ...renderTooltipContentKey, preferredLocale].join('-')}
          />
      )}

      Because isRendered remains true indefinitely on once-hovered rows, when the user scrolls the Search list and FlashList recycles rows, the row's text or data changes. The dynamic key immediately unmounts and remounts BaseGenericTooltip for hidden tooltips.

    3. Synchronous useLayoutEffect State Cascades:
      On every mount, BaseGenericTooltip (src/components/Tooltip/BaseGenericTooltip/index.tsx:69-83) executes useLayoutEffect:

      useLayoutEffect(() => {
          setContentMeasuredWidth(contentRef.current?.getBoundingClientRect().width);
          setWrapperMeasuredHeight(rootWrapper.current?.getBoundingClientRect().height);
      }, []);

      Calling setContentMeasuredWidth and setWrapperMeasuredHeight synchronously schedules immediate re-renders during the commit phase. Across recycled rows in ExpenseReportListItemRowWide and AvatarTooltipsProvider, these synchronous layout updates cause parent list containers to re-measure, triggering further cell updates and immediate remounts. React detects over 50 nested commits within the same cycle and throws Error: Maximum update depth exceeded.

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

    1. Unmount Inactive Hidden Tooltips in GenericTooltip.tsx:
      In src/components/Tooltip/GenericTooltip.tsx:

      • Reset setIsRendered(false) once the hide animation completes (or immediately in hideTooltip if animations are bypassed).
      • Only render BaseGenericTooltip while the tooltip is visible or animating:
        {shouldRender && isRendered && isVisible && (
            <BaseGenericTooltip ... />
        )}

      This ensures that recycled FlashList rows do not mount hidden BaseGenericTooltip instances or execute measurement layout effects when the user is simply scrolling.

    2. Add Equality Guards to Layout State Updates in BaseGenericTooltip/index.tsx:
      In src/components/Tooltip/BaseGenericTooltip/index.tsx:78-79, prevent unnecessary state dispatch if measurements haven't changed:

      const measuredWidth = contentRef.current?.getBoundingClientRect().width;
      const measuredHeight = rootWrapper.current?.getBoundingClientRect().height;
      
      setContentMeasuredWidth((prev) => (prev === measuredWidth ? prev : measuredWidth));
      setWrapperMeasuredHeight((prev) => (prev === measuredHeight ? prev : measuredHeight));

    What alternative solutions did you explore? (Optional)

    • Switching useLayoutEffect to useEffect:
      While moving state updates to useEffect avoids the synchronous depth crash, it causes noticeable visual layout flicker because tooltips render at 0/default bounds before repainting at their measured size. Resetting isRendered on hidden tooltips is the proper architectural solution.
    • Removing the dynamic key on BaseGenericTooltip:
      Removing the key avoids full component unmounts, but risks retaining stale content measurements when text length changes significantly. Unmounting hidden tooltips and equality-guarding measurement updates provides both safety and measurement accuracy.

    What automated tests can you add to prevent this from re-occurring?

    In tests/unit/GenericTooltipTest.tsx:

    1. Hidden Tooltip Unmount Test:
      Verify that calling hideTooltip() unmounts BaseGenericTooltip so that subsequent prop/text changes on the parent row do not trigger useLayoutEffect or measurement state updates.
    2. Measurement Depth Stress Test:
      Simulate rapid text prop updates on a mounted GenericTooltip container and assert that state transitions settle cleanly without exceeding React's maximum update depth.

    Contributor details

    Your Expensify account email: lkevinjosh10@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374

  10. ayolyn commented on Nov 3, 2026

    @ayolyn

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On web, scrolling or interacting with Search expense report rows (or list views rendering tooltips in recycled rows) crashes the app with a fatal React error:
    Error: Maximum update depth exceeded (React #185) originating from BaseGenericTooltip's useLayoutEffect measurement updates.


    What is the root cause of that problem?

    The issue stems from a combination of retained lazy-render state in GenericTooltip, key-based unmounting/remounting on recycled list rows, and synchronous state updates in useLayoutEffect:

    1. Stale isRendered on hidden tooltips:
      In src/components/Tooltip/GenericTooltip.tsx:95-97, showTooltip sets setIsRendered(true) and setIsVisible(true). When the mouse leaves the cell, hideTooltip (lines 146-158) sets setIsVisible(false) and scales the tooltip to 0, but isRendered permanently remains true.
    2. FlashList row recycling triggers hidden tooltip remounting:
      In GenericTooltip.tsx:203:
      key={[text, ...renderTooltipContentKey, preferredLocale].join('-')}
      When the user scrolls the Search list, FlashList recycles row components and updates row data (text prop). Because isRendered is still true, the changed key forces React to completely unmount and remount BaseGenericTooltip for hidden (closed) tooltips.
    3. Synchronous layout cascade in BaseGenericTooltip:
      On every remount of BaseGenericTooltip (src/components/Tooltip/BaseGenericTooltip/index.tsx:69-83), useLayoutEffect runs synchronously:
      setContentMeasuredWidth(contentRef.current?.getBoundingClientRect().width);
      setWrapperMeasuredHeight(rootWrapper.current?.getBoundingClientRect().height);
      Calling setState unconditionally inside useLayoutEffect triggers an immediate commit and re-render during layout phase. When FlashList recycles multiple rows during scrolling or container resize, mounting and measuring dozens of hidden tooltips in synchronous layout effects causes cascading re-renders that exceed React's 50-update nested depth limit, crashing the app into the error boundary.

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

    1. Unmount hidden tooltips on content/key change in src/components/Tooltip/GenericTooltip.tsx:

    When isVisible is false (the tooltip is closed/hidden) and the row is recycled or its text changes (prevText !== text), reset isRendered to false:

    useEffect(() => {
        if (!isVisible && isRendered && prevText !== undefined && prevText !== text) {
            setIsRendered(false);
        }
    }, [isVisible, isRendered, prevText, text]);
    • While the tooltip is open or animating, isVisible is true, so this effect does nothing.
    • When the tooltip is closed and FlashList reuses the row for a different item, isRendered becomes false. BaseGenericTooltip is cleanly unmounted, completely eliminating hidden tooltip measurement and layout effects during list scrolling.
    • When the user subsequently hovers over the cell, showTooltip() sets setIsRendered(true) and setIsVisible(true), mounting and measuring fresh dimensions accurately.

    2. Add equality guards to measurement updates in src/components/Tooltip/BaseGenericTooltip/index.tsx:

    In useLayoutEffect (src/components/Tooltip/BaseGenericTooltip/index.tsx:78-79), ensure state is only dispatched if the measured dimensions actually differ from current state:

    const measuredWidth = contentRef.current?.getBoundingClientRect().width;
    const measuredHeight = rootWrapper.current?.getBoundingClientRect().height;
    
    setContentMeasuredWidth((prev) => (prev === measuredWidth ? prev : measuredWidth));
    setWrapperMeasuredHeight((prev) => (prev === measuredHeight ? prev : measuredHeight));

    What alternative solutions did you explore? (Optional)

    1. Conditionally rendering BaseGenericTooltip only while isVisible is true ({shouldRender && isRendered && isVisible && <BaseGenericTooltip />}):
      Explored, but rejected because this immediately unmounts the component on mouse leave, abruptly cutting off the fade-out/scale-down animation and causing visual flickering. Resetting isRendered only when !isVisible AND content changes (prevText !== text) allows the exit animation to complete smoothly while guaranteeing that recycled rows never measure inactive tooltips.
    2. Switching useLayoutEffect to useEffect in BaseGenericTooltip:
      Rejected because moving initial measurement to useEffect introduces visible layout shift/flickering as tooltips render with undefined dimensions on the initial paint before snapping into place.

    What automated tests can you add to prevent this from re-occurring?

    In tests/unit/GenericTooltipTest.tsx:

    1. Recycled Row Test: Render GenericTooltip with initial text "Item A". Call showTooltip() and then hideTooltip(). Change the text prop to "Item B" while isVisible is false. Verify that BaseGenericTooltip is not mounted.
    2. Re-hover Test: Following the test above, call showTooltip(). Verify that BaseGenericTooltip mounts and renders with "Item B".

    Contributor details

    Your Expensify account email: juliusayolyn@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~0105126232377c4c5c

  11. 17 remaining items

  12. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Nov 7, 2026
  13. melvin-bot commented on Nov 7, 2026

    @melvin-bot

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

  14. TassioSales commented on Nov 8, 2026

    @TassioSales

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    In Search expense report rows, hover interactions and tooltip layout calculations cause an infinite render loop, crashing the web app with Error: Maximum update depth exceeded in BaseGenericTooltip.

    What is the root cause of that problem?

    In BaseGenericTooltip/index.tsx:

    1. When target components trigger tooltip measurements in onLayout or hover events, updateTargetBounds calls setTargetBounds(newBounds) on every layout pass.
    2. In search expense tables with dynamic cell widths and responsive containers, updating state triggers a parent row re-layout, which invokes onLayout again with newly generated object references (even when coordinates have not changed), creating an infinite setState loop.

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

    1. In BaseGenericTooltip/index.tsx:
      • Add a shallow equality check comparing previous bounds (x, y, width, height) before updating targetBounds state. If coordinates are identical within a sub-pixel threshold, do not invoke setTargetBounds.
      • Wrap layout recalculation callbacks in useCallback and debounce measurement calls during rapid hover transitions.

    What alternative solutions did you explore? (Optional)

    Using CSS-only tooltips for search rows, but maintaining BaseGenericTooltip preserves accessibility attributes and consistent tooltip styling across all platforms.

  15. mountiny commented on Nov 8, 2026

    @mountiny
    ContributorAuthor

    @gijoe0295 can you please review the proposals?

  16. gijoe0295 commented on Nov 8, 2026

    @gijoe0295
    Contributor

    Yes

  17. melvin-bot commented on Nov 11, 2026

    @melvin-bot

    @gijoe0295 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  18. TassioSales commented on Nov 12, 2026

    @TassioSales

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    In the Search expense report view (ExpenseReportListItemRowWide), rendering cells with tooltips (DateCell, TotalCell, etc.) can enter an infinite React render/layout loop throwing Error: Maximum update depth exceeded (React #185) in BaseGenericTooltip.

    What is the root cause of that problem?

    In TextWithTooltip/index.tsx, text truncation is measured in onLayout by checking whether scrollWidth > offsetWidth or scrollHeight > offsetHeight, which conditionally triggers setShowTooltip(true).

    When showTooltip becomes true, Tooltip/index.tsx conditionally switches from returning children directly to wrapping them in <BaseTooltip {...props}>{children}</BaseTooltip>. <BaseTooltip> wraps children inside <BoundsObserver> and <Hoverable> (a View container).

    This change in DOM/parent hierarchy alters the bounding box and flex styling around the inner <Text>, which immediately dispatches another onLayout event. In table rows where column widths sit right at the boundary threshold, the wrapped layout evaluates scrollWidth <= offsetWidth, causing setShowTooltip(false).

    When showTooltip becomes false, Tooltip/index.tsx unmounts <BaseTooltip>, removing the wrapper and returning children directly. This unmounting triggers yet another onLayout event on <Text>, re-evaluating scrollWidth > offsetWidth and calling setShowTooltip(true) again.

    Each remount of BaseGenericTooltip runs useLayoutEffect, which calls setContentMeasuredWidth and setWrapperMeasuredHeight synchronously during the commit phase. Because this mount/unmount cycle repeats on every layout event without settling, React rapidly hits its recursive update threshold and crashes with Maximum update depth exceeded.

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

    1. In src/components/Tooltip/types.ts and src/components/Tooltip/BaseTooltip/index.tsx:
      • Add shouldRender to SharedTooltipProps / TooltipProps and pass it down to <GenericTooltip shouldRender={shouldRender} {...props}>.
      • Update src/components/Tooltip/index.tsx to always render <BaseTooltip shouldRender={shouldRender} {...props}>{children}</BaseTooltip> rather than unmounting the wrapper tree when shouldRender is false. GenericTooltip already handles shouldRender natively to determine whether the tooltip bubble/overlay should be rendered (hasTooltipContent && shouldRender && isRendered), allowing the child element's DOM wrapper hierarchy to remain completely stable across truncation checks.
    2. In src/components/TextWithTooltip/index.tsx:
      • In onLayout, guard the state setter with an identity check: only call setShowTooltip when the computed truncation state differs from previous state: setShowTooltip((prev) => (prev !== isTruncated ? isTruncated : prev)).
      • Include a 1px threshold (scrollWidth - offsetWidth > 1) to eliminate subpixel rounding jitter on browser fractional zooms and responsive resize.

    What alternative solutions did you explore? (Optional)

    • Adding key resets in GenericTooltip: this causes remounting of tooltips rather than preventing the layout feedback oscillation.
    • Using useEffect instead of useLayoutEffect in BaseGenericTooltip: this causes visible positioning flicker on web when the tooltip first appears.

    What automated tests can you add to prevent this from re-occurring?

    In tests/unit/components/TooltipStableRenderTest.tsx, add a unit test that renders Tooltip with a monitored child component, toggles shouldRender between false and true multiple times, and verifies that the child component maintains a stable mount count of 1 without remounting or causing recursive update cycles.

    Contributor details
    Your Expensify account email: tassiolucian.ljs@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~0179cdc82689f205c7

  19. melvin-bot commented on Nov 12, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  20. samithreddychinni commented on Nov 12, 2026

    @samithreddychinni

    @gijoe0295 are you planning to add the Help Wanted label? i reproduced the crash, traced the update loop, and prepared a tested fix. if contributions are open, i can submit the proposal.

  21. gijoe0295 commented on Nov 12, 2026

    @gijoe0295
    Contributor

    I'm working on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions