Skip to content

[Due for payment 2026-04-07] [Due for payment 2026-04-03] Reports - App crashes after sending message and opening Reports > Chats #86454

Closed

Description

@jponikarchuk

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.3.49-0
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #85629
Email or phone of affected tester (no customers): snodijosdnjoijiosnj@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.2 / Chrome
App Component: Search

Action Performed:

  1. Go to staging.new.expensify.com
  2. Create a new Gmail account.
  3. Create a workspace.
  4. Go to workspace chat.
  5. Send a message.
  6. Delete the message (optional).
  7. Go to Reports > Chats.

Expected Result:

App will not crash.

Actual Result:

App crashes after sending message and opening Reports > Chats.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Video.mp4

logs.txt

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Mar 26, 2026
  2. melvin-bot commented on Mar 26, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #85629

  3. melvin-bot commented on Mar 26, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  4. github-actions commented on Mar 26, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  5. OSBotify commented on Mar 26, 2026

    @OSBotify
    Contributor

    Investigation Summary

    Classification: Frontend bug
    Causing PR: #85629 - "Defer API.write during Search screen transition to reduce perceived latency" by @JakubKorytko (High confidence)
    Related Issues: None

    Recommendation: REVERT

    The PR made significant changes to SearchContext navigation state extraction that are causing crashes when navigating to the Search page (Reports > Chats). A revert is the safest option to unblock the deploy while a proper fix is developed.

    Labels: No changes needed - DeployBlockerCash is correctly applied (Frontend bug blocking App deploy)

    Detailed Analysis

    Evidence

    Verification

    PR #85629 modified critical Search components:

    • src/components/Search/SearchContext.tsx - Refactored navigation state extraction
    • src/components/Search/index.tsx - Changed skeleton/loading logic
    • src/libs/deferredLayoutWrite.ts - New deferred write mechanism
    • Deleted src/components/Search/DeferredSearch/ wrapper components

    The most likely root cause is in SearchContext.tsx where the refactoring changed from a single navigation state extraction to multiple useNavigationState hooks:

    Before:

    const params = useMemo(() => {
        if (focusedScreenName !== SCREENS.SEARCH.ROOT) {
            return undefined;
        }
        return focusedScreenParams;
    }, [focusedScreenName, focusedScreenParams]);

    After:

    const queryParam = useNavigationState(selectSearchQueryParam);
    const rawQueryParam = useNavigationState(selectSearchRawQueryParam);

    Each selector calls getDeepestFocusedScreen(state) independently, which could cause render issues or infinite loops when navigation state changes rapidly during the message send → Reports navigation flow.

    Root Cause

    The refactoring introduced a timing issue where multiple navigation state subscriptions combined with the new deferred write mechanism causes a crash when navigating to the Search screen. The removal of the DeferredSearch wrapper component may have also eliminated important initialization logic that prevented this race condition.

  6. MelvinBot commented on Mar 26, 2026

    @MelvinBot
    Contributor

    Proposal

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

    The app crashes with TypeError: Cannot read properties of undefined (reading 'isLoading') when a user sends a message in a workspace chat and then navigates to Reports > Chats. This is reproducible on staging but not production, indicating it was introduced by a recent merge.

    What is the root cause of that problem?

    The crash originates from src/components/Search/index.tsx line 460, which was introduced/modified by PR #85629 ("Defer API.write during Search screen transition to reduce perceived latency").

    The problematic line uses incomplete optional chaining:

    searchResults?.search.isLoading
    

    The ?. only guards against searchResults being null/undefined. When searchResults is defined but searchResults.search is undefined, it evaluates undefined.isLoading, which throws the TypeError.

    This crash is now reachable because PR #85629 made two key changes:

    1. Removed the DeferredSearch wrapper component that previously delayed mounting the Search component until search data was ready.
    2. Changed the loading/defer logic so Search can now mount while searchResults is in a partially-populated state (e.g., Onyx has data set via a merge but search not yet populated).

    For context, line 466 in the same file correctly uses searchResults?.search?.isLoading with full optional chaining — the inconsistency on line 460 is the bug.

    The attached logs confirm the exact error and location:

    TypeError: Cannot read properties of undefined (reading 'isLoading')
        at Search_Search (authScreens.prefetch-...bundle.js:1:3100763)
    

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

    Change line 460 in src/components/Search/index.tsx from:

    const isSearchLoadingWithNoResults = !!searchResults?.search.isLoading && ...
    

    to:

    const isSearchLoadingWithNoResults = !!searchResults?.search?.isLoading && ...
    

    This adds the missing ?. so that when searchResults.search is undefined, the expression short-circuits to undefined (falsy) instead of throwing.

    What alternative solutions did you explore? (Optional)

    An alternative would be to revert PR #85629 entirely. However, since the root cause is a simple missing optional chaining operator (and the rest of the file already uses ?.search?. correctly on line 466), the targeted one-character fix is safer and preserves the performance improvements from the PR.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot to refine this analysis, or explain why you are rejecting Melvin's proposal.

  7. JakubKorytko commented on Mar 26, 2026

    @JakubKorytko
    Member

    Taking a look 👀

  8. JakubKorytko commented on Mar 26, 2026

    @JakubKorytko
    Member

    Fix ready: #86462

  9. IuliiaHerets commented on Mar 26, 2026

    @IuliiaHerets

    Issue is not reproduced anymore, build 9.3.49-2

    1774551558895.chat.mp4
  10. 5 remaining items

  11. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Mar 27, 2026
  12. changed the title [-]Reports - App crashes after sending message and opening Reports > Chats[/-] [+][Due for payment 2026-04-03] Reports - App crashes after sending message and opening Reports > Chats[/+] on Mar 27, 2026
  13. melvin-bot commented on Mar 27, 2026

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  14. melvin-bot commented on Mar 27, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.49-2 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2026-04-03. 🎊

    For reference, here are some details about the assignees on this issue:

  15. melvin-bot commented on Mar 27, 2026

    @melvin-bot

    @luacmartins @JakubKorytko The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  16. melvin-bot commented on Mar 27, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  17. changed the title [-][Due for payment 2026-04-03] Reports - App crashes after sending message and opening Reports > Chats[/-] [+][Due for payment 2026-04-07] [Due for payment 2026-04-03] Reports - App crashes after sending message and opening Reports > Chats[/+] on Mar 31, 2026
  18. melvin-bot commented on Mar 31, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.50-8 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2026-04-07. 🎊

    For reference, here are some details about the assignees on this issue:

  19. melvin-bot commented on Mar 31, 2026

    @melvin-bot

    @luacmartins @mallenexpensify @JakubKorytko The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.EngineeringWeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions