Skip to content

[Due for payment 2025-06-16] [Due for payment 2025-06-13] [$250] WS Chat - After deleting an expense, it navigates to different chat instead of the main chat #62568

Closed

Description

@nlemma

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: v9.1.49-4
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: Exp
Email or phone of affected tester (no customers): applausetester+bm588@applause.expensifail.com
Issue reported by: Applause Internal Team
Device used: Web
App Component: Chat Report View

Action Performed:

Precondition -
Use Expensifail account

  1. Go to https://staging.new.expensify.com/
  2. As user A, create a workspace and add user B as a member
  3. As user B, go to the WS chat and create an expense
  4. As user A, go to the WS chat of user B and open the expense
  5. As user B, delete the expense

Expected Result:

After user B deletes the expense, user A should navigate back to the main chat

Actual Result:

After user B deletes the expense, user A navigates to another chat.

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

Bug6839050_1747905917576.bandicam_2025-05-22_12-11-56-830.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021926946552701025730
  • Upwork Job ID: 1926946552701025730
  • Last Price Increase: 2025-05-26
Issue OwnerCurrent Issue Owner: @flaviadefaria

Activity

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

    @melvin-bot

    Triggered auto assignment to @flaviadefaria (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. dmkt9 commented on May 24, 2025

    @dmkt9
    Contributor

    Proposal

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

    After user B deletes the expense, user A navigates to another chat.

    What is the root cause of that problem?

    • When the app receives an event from the server and calls a navigate command here:
      Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(prevReport.parentReportID));
    • If the persistence mechanism (which saves the navigation state) is in the middle of rehydration, the previously saved state will be applied once rehydration completes. This process overrides the new navigation command triggered by the server, causing the navigator to revert to its initial route.

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

    • Ensure the navigate command is executed only if Navigation.isNavigationReady() ready:
      Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(prevReport.parentReportID));
    Navigation.isNavigationReady().then(() => {
        Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(prevReport.parentReportID));
    });

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    NA

    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.

    Result:

    bandicam.2025-05-25.09-12-26-930.mp4
  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on May 26, 2025
  5. changed the title [-]WS Chat - After deleting an expense, it navigates to different chat instead of the main chat[/-] [+][$250] WS Chat - After deleting an expense, it navigates to different chat instead of the main chat[/+] on May 26, 2025
  6. melvin-bot commented on May 26, 2025

    @melvin-bot
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on May 26, 2025
  8. melvin-bot commented on May 26, 2025

    @melvin-bot

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

  9. flaviadefaria commented on May 26, 2025

    @flaviadefaria
    Contributor

    Added the external label.

  10. truph01 commented on May 26, 2025

    @truph01
    Contributor

    Proposal

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

    • After user B deletes an expense, user A is incorrectly navigated to a different chat.

    What is the root cause of that problem?

    • When an expense is deleted, three navigation actions are triggered sequentially:

    • The second navigation is delayed until Navigation.isNavigationReady() resolves. This causes the navigation actions to execute in the following order: first > third > second, instead of the intended sequence.

    • This out-of-order execution leads to incorrect navigation. For example, consider the following screen stack on user A’s side (after step 4 in OP):

    STACK
    └── ReportsSplitNavigator
        └── STACK
            ├── Home
            ├── Report Screen (A) - Another report
            ├── Report Screen (B) - Policy expense chat
            └── Report Screen (C) - Expenses chat
    
    • Step-by-step behavior:
      1. The first navigation action is a no-op since there’s no modal to dismiss.
      2. The third navigation pushes the parent report (Report B), resulting in:
    STACK
    └── ReportsSplitNavigator
        └── STACK
            ├── Home
            ├── Report Screen (A) - Another report
            ├── Report Screen (B) - Policy expense chat
            ├── Report Screen (C) - Expenses chat
            └── Report Screen (B) - Policy expense chat
    
    1. The second navigation action (delayed by Navigation.isNavigationReady()) then calls popToTop, collapsing the stack to:
    STACK
    └── ReportsSplitNavigator
        └── STACK
            ├── Home
            └── Report Screen (A) - Another report
    
    • This unintended popToTop causes the user to be redirected away from the expected screen.

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

    • The call to Navigation.isNavigationReady() was added in this PR to ensure safe navigation when the RHP is open.

    • However, in the scenario where no RHP is open, wrapping popToSidebar() in Navigation.isNavigationReady() causes unnecessary delay and incorrect order of operations.

    • We should update the logic at lines 622–624 to the following:

    
    if (isReportDetailOpenInRHP) {
        Navigation.isNavigationReady().then(() => {
            Navigation.popToSidebar();
        });
    } else {
        Navigation.popToSidebar();
    }
    

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    • None

    What alternative solutions did you explore? (Optional)

    • An extended version of the solution involves refining the broader navigation block starting from line 621:
    
    if (Navigation.getTopmostReportId() === prevOnyxReportID) {
        if (isReportDetailOpenInRHP) {
            Navigation.isNavigationReady().then(() => {
                Navigation.popToSidebar();
            });
        } else {
            Navigation.popToSidebar();
        }
    }
    if (prevReport?.parentReportID) {
        // Prevent navigation to the IOU/Expense Report if it is pending deletion.
        if (isMoneyRequestReportPendingDeletion(prevReport.parentReportID)) {
            return;
        }
        if (isReportDetailOpenInRHP) {
            Navigation.isNavigationReady().then(() => {
                            InteractionManager.runAfterInteractions(() => {
                                Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(prevReport.parentReportID));
                            });
            });
        } else {
            Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(prevReport.parentReportID));
        }
        return;
    }
    if (isReportDetailOpenInRHP) {
        Navigation.isNavigationReady().then(() => {
            InteractionManager.runAfterInteractions(() => {
                navigateToConciergeChat();
            });
        });
    } else {
        navigateToConciergeChat();
    }
    
  11. 39 remaining items

  12. melvin-bot commented on Jun 16, 2025

    @melvin-bot

    Payment Summary

    Upwork Job

    • Reviewer: @rojiphil owed $250 via NewDot
    • ROLE: @dmkt9 paid $(AMOUNT) via Upwork (LINK)

    BugZero Checklist (@flaviadefaria)

    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1926946552701025730/hired)
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  13. melvin-bot commented on Jun 16, 2025

    @melvin-bot

    @flaviadefaria Whoops! This issue is 2 days overdue. Let's get this updated quick!

  14. rojiphil commented on Jun 17, 2025

    @rojiphil
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production
    • 2b. Reported on staging (deploy blocker)
    • 2c. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment:

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: Not Required. The existing checklist is good enough to capture such issues.

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    Regression Test Proposal

    Precondition:

    Test:

    1. Go to staging.new.expensify.com
    2. As user A, create a workspace and add user B as a member.
    3. As user B, go to the WS chat and create an expense.
    4. As user A, go to the WS chat of user B and open the expense.
    5. As user B, delete the expense.
    6. Note that after user B deletes the expense, user A is navigated back to the main chat.

    Do we agree 👍 or 👎

  15. rojiphil commented on Jun 17, 2025

    @rojiphil
    Contributor

    @flaviadefaria BZ Checklist done. Thanks.

  16. melvin-bot commented on Jun 18, 2025

    @melvin-bot

    @flaviadefaria Eep! 4 days overdue now. Issues have feelings too...

  17. flaviadefaria commented on Jun 18, 2025

    @flaviadefaria
    Contributor

    @dmkt9 I sent you an offer on Upwork. As soon as you accept it, I'll be able to pay you.

  18. dmkt9 commented on Jun 18, 2025

    @dmkt9
    Contributor

    @dmkt9 I sent you an offer on Upwork. As soon as you accept it, I'll be able to pay you.

    @flaviadefaria Thank you. I have accepted and submitted the offer.

  19. flaviadefaria commented on Jun 18, 2025

    @flaviadefaria
    Contributor
  20. flaviadefaria commented on Jun 18, 2025

    @flaviadefaria
    Contributor

    Payment Summary

    Reviewer: @rojiphil owed $250 via NewDot (Needs to be requested)
    ROLE: @dmkt9 paid $250 via Upwork (Paid)

  21. garrettmknight commented on Jun 19, 2025

    @garrettmknight
    Contributor

    $250 approved for @rojiphil

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.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorMonthlyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions