Skip to content

[Due for payment 2025-03-21] [$250] Reports - Merchant page is not dismissed after clicking Discard changes #57512

Closed

Description

@mitarachim

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.1.7-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
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+923093292@applause.expensifail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.3 / Chrome
App Component: Search

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Submit an expense.
  4. Go to Reports.
  5. Click on the expense from Step 3.
  6. Click Merchant.
  7. Edit the merchant but do not click Save.
  8. Click RHP back button.
  9. Click Discard changes.

Expected Result:

Merchant page will be dismissed after clicking Discard changes.

Actual Result:

Merchant page is not dismissed after clicking Discard changes.

This issue only happens in Reports.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6755685_1740616530656.20250227_082826.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021895179711497701073
  • Upwork Job ID: 1895179711497701073
  • Last Price Increase: 2025-02-27
Issue OwnerCurrent Issue Owner: @slafortune

Activity

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

    @melvin-bot

    Triggered auto assignment to @slafortune (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. truph01 commented on Feb 27, 2025

    @truph01
    Contributor

    Proposal

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

    • Merchant page is not dismissed after clicking Discard changes.

    What is the root cause of that problem?

    • Assume that the current stacks are:
    Root Stack
    │── Search_Root 
    │   └── RightModalNavigator (key: stack-i_bdG4cQcnIHXNiaX1nte)
    │       ├── SearchReport
    │       │   └── Search_Report_RHP 
    │       ├── MoneyRequest (key: stack-K5cl_VClhnmoe7Mt9GbQE)
    │       │   └── Money_Request_Step_Merchant 
    
    • When user clicks on the discard button in the confirmation modal, it calls:

    navigation.dispatch(blockedNavigationAction.current);

    with the navigation action is:

    {
        "type": "POP",
        "payload": { "count": 1 },
        "target": "stack-i_bdG4cQcnIHXNiaX1nte"
    }
    

    As we can see, the target refers to the RightModalNavigator, but the current screen is in MoneyRequest, so dispatching the pop action above does nothing.

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

    • We can remove the target prop from the navigation action so the POP action will start from MoneyRequest and bubble to other navigators if not handled by the current navigator:

    navigation.dispatch(blockedNavigationAction.current);

                        const blockActionWithouTarget = {...blockedNavigationAction.current};
                        delete blockActionWithouTarget.target;
                        navigation.dispatch(blockActionWithouTarget);
    
    • We can consider only removing the target if the navigation action is POP.

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

    • It is navigation issue so test does not need.

    What alternative solutions did you explore? (Optional)

  4. bernhardoj commented on Feb 27, 2025

    @bernhardoj
    Contributor

    Proposal

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

    Merchant page isn't dismissed when discarding merchant changes if we open it from report RHP.

    What is the root cause of that problem?

    When we confirm the discard, it will dispatch whatever action that is previously prevented.

    useBeforeRemove(
    useCallback(
    (e) => {
    if (!getHasUnsavedChanges()) {
    return;
    }
    e.preventDefault();
    blockedNavigationAction.current = e.data.action;
    setIsVisible(true);
    },
    [getHasUnsavedChanges],
    ),
    );

    onConfirm={() => {
    setIsVisible(false);
    if (blockedNavigationAction.current) {
    navigation.dispatch(blockedNavigationAction.current);
    }
    }}

    In our case, it's a POP action from our goUp function. The target of the pop is the RightModalNavigator with a count of 1.

    navigationRef.current.dispatch({...StackActions.pop(distanceToPop), target: targetState.key});

    If we open the merchant page from the report RHP, the RightModalNavigator has 2 routes: [ReportRHP, MerchantPage]. So, popping 1 screen will pop MerchantPage. However, it has no effect at all.

    That's because we dispatch the navigation action using the navigation object from useNavigation, which in this case, is the navigation object from merchant screen.

    navigation.dispatch(blockedNavigationAction.current);

    compared to the goUp where we use navigationRef which is the root one.

    navigationRef.current.dispatch({...StackActions.pop(distanceToPop), target: targetState.key});

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

    We need to dispatch the action using navigationRef too in discard logic.

    navigation.dispatch(blockedNavigationAction.current);

    navigationRef.current?.dispatch(blockedNavigationAction.current);
    

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

    I think we can test by rendering the navigation container with the RightModalNavigator, then navigate to the merchant page with backTo param and simulate the action done in this issue.

  5. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Feb 27, 2025
  6. changed the title [-]Reports - Merchant page is not dismissed after clicking Discard changes[/-] [+][$250] Reports - Merchant page is not dismissed after clicking Discard changes[/+] on Feb 27, 2025
  7. melvin-bot commented on Feb 27, 2025

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

    @melvin-bot

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

  10. c3024 commented on Feb 28, 2025

    @c3024
    Contributor

    Thanks for the proposals.

    I agree with the RCA that the navigation object obtained via useNavigation within DiscardChangesConfirmation is scoped to the nearest stack. As a result, this navigation object does not include the stack on which the dispatched action for goBack (and consequently goUp) should act.

    Instead of removing the target of this action, I think we should provide the correct navigation object in DiscardChangesConfirmation for this action to execute properly. So, @bernhardoj’s proposal to dispatch the action on the root ref looks good to me!

  11. c3024 commented on Feb 28, 2025

    @c3024
    Contributor

    🎀 👀 🎀 C+ reviewed!

  12. 16 remaining items

  13. changed the title [-][$250] Reports - Merchant page is not dismissed after clicking Discard changes[/-] [+][Due for payment 2025-03-21] [$250] Reports - Merchant page is not dismissed after clicking Discard changes[/+] on Mar 14, 2025
  14. melvin-bot commented on Mar 14, 2025

    @melvin-bot

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

  15. melvin-bot commented on Mar 14, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.12-7 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 2025-03-21. 🎊

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

    • @bernhardoj requires payment through NewDot Manual Requests
    • @c3024 requires payment through NewDot Manual Requests
  16. melvin-bot commented on Mar 14, 2025

    @melvin-bot

    @c3024 @slafortune @c3024 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]

  17. c3024 commented on Mar 20, 2025

    @c3024
    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 (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. 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: https://github.com/Expensify/App/pull/54176/files#r2004997401

    • [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: The added modal is a new feature. This is not a critical bug so no discussion was started.

    • [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 Template

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Precondition:

    • Have a money request in workspace chat.

    Test:

    1. Open Reports page from bottom tab
    2. Open the money request
    3. Press on the merchant
    4. Type anything
    5. Press back
    6. Press Discard changes
    7. Verify that the merchant page closes

    Do we agree 👍 or 👎

  18. melvin-bot commented on Mar 21, 2025

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@slafortune)

    • 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/1895179711497701073/hired)
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  19. bernhardoj commented on Mar 21, 2025

    @bernhardoj
    Contributor

    Requested in ND.

  20. slafortune commented on Mar 22, 2025

    @slafortune
    Contributor

    Role Contributor - @bernhardoj owed $250 via NewDot
    Role C+ - @c3024 owed $250 via NewDot

  21. moved this from Bugs and Follow Up Issues to Done in #expensify-bugson Mar 22, 2025
  22. JmillsExpensify commented on Mar 24, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @bernhardoj

  23. JmillsExpensify commented on Apr 9, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @c3024

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 contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions