Skip to content

[Due for payment 2025-04-02] [$250] mWeb - Workspace - Tapping New Workspace more than once, opens several WS confirmation pages #57824

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.9-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: N/A
Email or phone of affected tester (no customers): ibellicotest+345@gmail.com
Issue reported by: Applause Internal Team
Device used: Motorola MotoG60 - Android 12 - Chrome
App Component: Workspace Settings

Action Performed:

Prerequisite: At least one workspace should be already created on account.

  1. Open the staging.new.expensify.com
  2. Tap on "Settings" and select "Workspaces"
  3. Tap on "New Workspace" button more than once.
  4. When landing on "Confirm Workspace" page, tap on the arrow on the top left corner to return to workspaces list.
  5. Check how many workspaces confirmation pages were opened.

Expected Result:

Only one workspace confirmation page should be opened despite tapping more than once on "New Workspace" button.

Actual Result:

Several workspace confirmation pages are opened if tapping more than once on "New Workspace" button.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6761517_1741152588965.WS_several.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021897404729148638725
  • Upwork Job ID: 1897404729148638725
  • Last Price Increase: 2025-03-12
  • Automatic offers:
    • dominictb | Reviewer | 106528962
    • Krishna2323 | Contributor | 106528964
Issue OwnerCurrent Issue Owner: @greg-schroeder

Activity

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

    @melvin-bot

    Triggered auto assignment to @greg-schroeder (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. daledah commented on Mar 5, 2025

    @daledah
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-03-06 10:06:35 UTC.

    Proposal

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

    Several workspace confirmation pages are opened if tapping more than once on "New Workspace" button.

    What is the root cause of that problem?

    In Workspace List page, we don't prevent multiple click on New workspace button

    onPress={() => interceptAnonymousUser(() => Navigation.navigate(ROUTES.WORKSPACE_CONFIRMATION.getRoute(Navigation.getActiveRoute())))}

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

    We can modify and use the logics added in this PR, which was implemented to fix this similar issue.

    First, modify useActiveRoute to use other Navigation methods instead of only getReportRHPActiveRoute

    Here's my initial pseudo code, this can be further improved if we get to the PR phase

    const currentRoute = useRef('');
    
    const getCurrentRoute = useCallback((callback: () => string) => {
            if (!currentRoute.current) {
                currentRoute.current = callback();
            }
    
            return currentRoute.current;
    }, []);

    Then use it in Workspace List page

    const {getCurrentRoute} = useActiveRoute();
    
    const getHeaderButton = () => (
            <Button
                accessibilityLabel={translate('workspace.new.newWorkspace')}
                text={translate('workspace.new.newWorkspace')}
                onPress={() => interceptAnonymousUser(() => Navigation.navigate(ROUTES.WORKSPACE_CONFIRMATION.getRoute(getCurrentRoute(Navigation.getActiveRoute))))}
                icon={Expensicons.Plus}
                style={[shouldUseNarrowLayout && styles.flexGrow1, shouldUseNarrowLayout && styles.mb3]}
            />
        );

    Then we can use this hook to fix the similar bugs in other places.

    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)

    Create a ref:

    const isButtonPressedRef = useRef(false)

    Update onPress for New workspace button

    onPress={() => {
    		if (isButtonPressedRef.current) {
                        return;
                    }
                    isButtonPressedRef.current = true;
    		interceptAnonymousUser(() => {
    			Navigation.navigate(ROUTES.WORKSPACE_CONFIRMATION.getRoute(Navigation.getActiveRoute()))
    		})
    	}
    }

    And reset isButtonPressedRef when Workspace List page gain focus

        const isFocused = useIsFocused();
    
        useEffect(() => {
            if (!isFocused) {
                return;
            }
            pressedRef.current = false;
        }, [isFocused]);

    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.

  4. linhvovan29546 commented on Mar 5, 2025

    @linhvovan29546
    Contributor

    Proposal

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

    mWeb - Workspace - Tapping New Workspace more than once, opens several WS confirmation pages

    What is the root cause of that problem?

    On the web, when clicking a button, we do not handling singleExecution as we do on native, so the onPress fired multiple time.
    When a button is clicked, we navigate to the target screen. However, in this case, the navigation action is triggered multiple times.

    export default function useSingleExecution() {

    Although we have logic to prevent navigation to the same screen, in the OP, we navigate with backTo, which causes the condition to evaluate as false, leading to multiple instances of the screen opening.

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

    We can use debounce to prevent multiple click

    onPress={() => interceptAnonymousUser(() => Navigation.navigate(ROUTES.WORKSPACE_CONFIRMATION.getRoute(Navigation.getActiveRoute())))}

        const debounceOnPress = useDebounce(
            (action) => action(),
            CONST.TIMING.USE_DEBOUNCED_STATE_DELAY,
            {
                leading: true, trailing: false 
            }
        );
    .....
                onPress={() =>
                    debounceOnPress(()=>{
                        interceptAnonymousUser(() => Navigation.navigate(ROUTES.WORKSPACE_CONFIRMATION.getRoute(Navigation.getActiveRoute())))
                    })}

    Optional: We can wrap this inside Button

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

    We can write a test to verify that action is only executed one time times when clicking multiple times

    What alternative solutions did you explore? (Optional)

    n/A

  5. Krishna2323 commented on Mar 5, 2025

    @Krishna2323
    Contributor

    Proposal

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

    mWeb - Workspace - Tapping New Workspace more than once, opens several WS confirmation pages

    What is the root cause of that problem?

    • On web, we do not prevent multiple clicks. We have logic to prevent navigation to the same screen but as soon as we hit the "New workspace" button, the Navigation.getActiveRoute() and due to that the url is not identified as same.

    // We don't want to dispatch action to push/replace with exactly the same route that is already focused.
    if (areNamesAndParamsEqual(currentState, stateFromPath)) {
    return;
    }

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

    • Instead of passing Navigation.getActiveRoute() as backTo value, we can use ROUTES.SETTINGS_WORKSPACES.
    • We should also do the same if the bug exist in other components/pages.

    onPress={() => interceptAnonymousUser(() => Navigation.navigate(ROUTES.WORKSPACE_CONFIRMATION.getRoute(Navigation.getActiveRoute())))}

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

    N/A -- Navigation issue

    What alternative solutions did you explore? (Optional)

    • We can use isFocused to prevent navigating when screen is not focused.
                onPress={() =>
                    interceptAnonymousUser(() => {
                        if (!isFocused) {
                            return;
                        }
                        Navigation.navigate(ROUTES.WORKSPACE_CONFIRMATION.getRoute(ROUTES.SETTINGS_WORKSPACES));
                    })
                }
  6. huult commented on Mar 5, 2025

    @huult
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-03-06 02:08:18 UTC.

    Proposal

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

    Tapping New Workspace more than once, opens several WS confirmation pages

    What is the root cause of that problem?

    When we tap 'New Workspace' multiple times, the navigation is triggered repeatedly, causing this issue.

    onPress={() => interceptAnonymousUser(() => Navigation.navigate(ROUTES.WORKSPACE_CONFIRMATION.getRoute(Navigation.getActiveRoute())))}

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

    This issue might occur elsewhere if reproduced with similar behavior. I haven't tested it, but I assume so. Therefore, I suggest two solutions: 1) a fix for this specific issue, and 2) a global fix.

    1. A fix for this specific issue: We should call navigate only when activeRoute differs from newRoute

    onPress={() => interceptAnonymousUser(() => Navigation.navigate(ROUTES.WORKSPACE_CONFIRMATION.getRoute(Navigation.getActiveRoute())))}

    update to:

        const activeRoute = Navigation.getActiveRoute();
        const newRoute = ROUTES.WORKSPACE_CONFIRMATION.getRoute(activeRoute);
        const extractBaseRoute = (route: string) => route.split('?').at(0);
    
        // or
        // const removeBacktoParam = (r: string) => r.replace(/([&?])backTo=[^&]+(&|$)/, (match, p1, p2) => (p1 === '?' && !p2 ? '' : p1));
    
        // if (removeBacktoParam(activeRoute) === removeBacktoParam(`/${newRoute}`)) {
    
        if (extractBaseRoute(activeRoute) === extractBaseRoute(`/${newRoute}`)) {
            return;
        }
    
        Navigation.navigate(newRoute);
    Screen.Recording.2025-03-05.at.16.05.28.mov
    1. Global fix: We apply the same approach by checking if newRoute differs from activeRoute. If they are different, we allow navigation; otherwise, navigation is not needed (optional)

    if (!canNavigate('navigate', {route})) {

    add:

        const activeRoute = getActiveRoute();
    
        const removeBacktoParam = (r: string) => r.replace(/([&?])backTo=[^&]+(&|$)/, (match, p1, p2) => (p1 === '?' && !p2 ? '' : p1));
    
        if (removeBacktoParam(activeRoute) === removeBacktoParam(`/${route}`)) {
            return;
        }

    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)

    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.

  7. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Mar 5, 2025
  8. changed the title [-]mWeb - Workspace - Tapping New Workspace more than once, opens several WS confirmation pages[/-] [+][$250] mWeb - Workspace - Tapping New Workspace more than once, opens several WS confirmation pages[/+] on Mar 5, 2025
  9. melvin-bot commented on Mar 5, 2025

    @melvin-bot
  10. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Mar 5, 2025
  11. melvin-bot commented on Mar 5, 2025

    @melvin-bot

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

  12. 22 remaining items

  13. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Mar 26, 2025
  14. changed the title [-][$250] mWeb - Workspace - Tapping New Workspace more than once, opens several WS confirmation pages[/-] [+][Due for payment 2025-04-02] [$250] mWeb - Workspace - Tapping New Workspace more than once, opens several WS confirmation pages[/+] on Mar 26, 2025
  15. melvin-bot commented on Mar 26, 2025

    @melvin-bot

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

  16. melvin-bot commented on Mar 26, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.18-4 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-04-02. 🎊

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

  17. melvin-bot commented on Mar 26, 2025

    @melvin-bot

    @dominictb @greg-schroeder @dominictb 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]

  18. dominictb commented on Mar 27, 2025

    @dominictb
    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/53845/files#r2017049175

    • [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: NA

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

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

    • Account should not have any existing workspace

    Test:

    1. Open the workspace switcher.
    2. Press the "Get Started" button multiple times in quick succession > Verify that only one Workspace Confirmation page opens.
    3. Navigate back, then go to Settings > Workspaces.
    4. Press the "New Workspace" button multiple times in quick succession > Verify that only one Workspace Confirmation page opens.
    5. Press the back button and verify that you are correctly navigated back to the Workspaces list page.
    6. Press "New Workspace," create the workspace, and then go back to the Workspaces list page.
    7. Press the "New Workspace" button multiple times in quick succession > Verify that only one Workspace Confirmation page opens.
    8. Press the back button > Verify that you are correctly navigated back to the Workspaces list page.

    Do we agree 👍 or 👎

  19. greg-schroeder commented on Mar 31, 2025

    @greg-schroeder
    Contributor

    Filed regression test, pending payment date

  20. greg-schroeder commented on Apr 2, 2025

    @greg-schroeder
    Contributor

    Payment summary:

    Contributor: @Krishna2323 - $250 - Upwork
    C+: @dominictb - $250 - Upwork

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