Skip to content

[$250] Reports - App crashes when clicking browser back button on report view while on selection mode #70068

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.2.2-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: https://test-management.browserstack.com/projects/2219752/test-runs/TR-701/folder/13176730/41237116/881812749
Email or phone of affected tester (no customers): applausetester+khcategory19@applause.expensifail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.5 / Chrome
App Component: Search

Action Performed:

Precondition:

  • Account has many expense reports (more than 50).
  1. Go to staging.new.expensify.com
  2. Go to Reports > Reports.
  3. Select all expenses via checkbox.
  4. Click on any expense report.
  5. Click browser back button.

Expected Result:

App will not crash.

Actual Result:

App crashes when clicking browser back button on report view while on selection mode.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

1.mp4

logs.txt

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022003564641995881362
  • Upwork Job ID: 2003564641995881362
  • Last Price Increase: 2025-12-30
Issue OwnerCurrent Issue Owner: @alitoshmatov

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 8, 2025
  2. melvin-bot commented on Sep 8, 2025

    @melvin-bot

    Triggered auto assignment to @bfitzexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. added
    InternalRequires API changes or must be handled by Expensify staff
    on Sep 9, 2025
  4. bfitzexpensify commented on Sep 9, 2025

    @bfitzexpensify
    Contributor

    Tagged to #quality, internal label added

  5. bfitzexpensify commented on Sep 9, 2025

    @bfitzexpensify
    Contributor

    Going to set to Weekly for the moment while awaiting a volunteer to take this on

  6. changed the title [-]Reports - App crashes when clicking browser back button on report view while on selection mode[/-] [+][BACK BUTTON] [HOLD on #59245] Reports - App crashes when clicking browser back button on report view while on selection mode[/+] on Sep 11, 2025
  7. twisterdotcom commented on Sep 11, 2025

    @twisterdotcom
    Contributor

    Hello assignees. We came to the conclusion in #57969 that the back buttons in the app behave inconsistently and in a way that we don't think is ideal, but that fixing the issue is a potentially high cost, low reward situation. We are going to start tracking these issues and attempt to find a way and somebody who can help solve this problem heuristically across the app.

    I have HELD a lot of issues related to the "back button" but any that are currently Reviewing or Due for payment I have not held. If you believe your issue shouldn't be linked or HELD, comment with the explanation and I will review and unlike/remove the hold. Thank you!

  8. 29 remaining items

  9. melvin-bot commented on Dec 23, 2025

    @melvin-bot

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

  10. self-assigned this
    on Dec 23, 2025
  11. daledah commented on Dec 23, 2025

    @daledah
    Contributor

    Proposal

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

    App crashes when clicking browser back button on report view while on selection mode.

    What is the root cause of that problem?

    When navigating back via the browser back button:

    • The Search screen comes into focus
    • useFocusEffect runs and updates SearchContext state

    useFocusEffect(clearTransactionsAndSetHashAndKey);

    • The Search component is still rendering and accessing searchResults.data

    const report = searchResults.data[`${ONYXKEYS.COLLECTION.REPORT}${transaction.reportID}`];
    const policy = searchResults.data[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`];

    • This triggers React error 185

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

    We should defer state updates using requestAnimationFrame so they run after render

        useFocusEffect(
            useCallback(() => {
                // Defer state updates to avoid React error #185 (Cannot update a component while rendering a different component)
                // This can happen when navigating back via browser back button while in selection mode
                requestAnimationFrame(() => {
                    clearTransactionsAndSetHashAndKey();
                });
            }, [clearTransactionsAndSetHashAndKey]),
        );
    

    useFocusEffect(clearTransactionsAndSetHashAndKey);

    And add null checks to safely handle navigation transitions

        const filteredViolations = useMemo(() => {
            if (!violations || !searchResults?.data || typeof searchResults.data !== 'object') {
                return violations;
            }
    

    const filteredViolations = useMemo(() => {
    if (!violations || !searchResults?.data) {
    return violations;
    }

    What alternative solutions did you explore? (Optional)

    NA

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  12. melvin-bot commented on Dec 26, 2025

    @melvin-bot

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

  13. melvin-bot commented on Dec 30, 2025

    @melvin-bot

    📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

  14. melvin-bot commented on Jan 1, 2026

    @melvin-bot

    @alitoshmatov 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

  15. mvtglobally commented on Jan 4, 2026

    @mvtglobally

    Issue not reproducible during KI retests. (First week)

  16. arosiclair commented on Jan 5, 2026

    @arosiclair
    Contributor

    This is not reproducible anymore in v9.2.93-1

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 contributorHelp WantedApply this label when an issue is open to proposals by contributors

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions