Skip to content

[HOLD for payment 2024-10-07] Workspace - Invite message comes back after deleting it #49899

Closed

Description

@lanitochka17

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.0.41-2
Reproducible in staging?: Y
Reproducible in production?: N
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): applausetester+ds@applause.expensifail.com
Issue reported by: Applause - Internal Team

Action Performed:

  1. Login to an account
  2. Create a workspace
  3. Go to the created workspace > Members
  4. Click on invite member > Choose a user
  5. On "add message" page try to delete the message

Expected Result:

Message is deleted

Actual Result:

The deleted message comes back

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6618028_1727488696018.Screen_Recording_2024-09-28_at_4.50.36_at_night.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @JmillsExpensify

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    DeployBlockerIndicates it should block deploying the API
    on Sep 29, 2024
  2. melvin-bot commented on Sep 29, 2024

    @melvin-bot

    Triggered auto assignment to @dangrous (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  3. github-actions commented on Sep 29, 2024

    @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.
  4. Nodebrute commented on Sep 29, 2024

    @Nodebrute
    Contributor

    Edited by proposal-police: This proposal was edited at 2024-09-29 18:55:32 UTC.

    Proposal

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

    Invite message comes back after deleting it

    What is the root cause of that problem?

    We are setting setWelcomeNote(getDefaultWelcomeNote()) again here

    useEffect(() => {
    if (isEmptyObject(invitedEmailsToAccountIDsDraft)) {
    return;
    }
    setWelcomeNote(getDefaultWelcomeNote());
    }, [getDefaultWelcomeNote, invitedEmailsToAccountIDsDraft]);

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

    We can remove this code block

    useEffect(() => {
    if (isEmptyObject(invitedEmailsToAccountIDsDraft)) {
    return;
    }
    setWelcomeNote(getDefaultWelcomeNote());
    }, [getDefaultWelcomeNote, invitedEmailsToAccountIDsDraft]);

    We should test the code to make sure everything is working properly

    What alternative solutions did you explore? (Optional)

  5. Krishna2323 commented on Sep 29, 2024

    @Krishna2323
    Contributor

    Edited by proposal-police: This proposal was edited at 2024-09-29 19:17:45 UTC.

    Proposal


    Offending PR: #48660

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

    Workspace - Invite message comes back after deleting it

    What is the root cause of that problem?

    • We have multiple useEffect hooks to set the welcome note when the component mounts or the members change.

    useEffect(() => {
    if (!isEmptyObject(invitedEmailsToAccountIDsDraft)) {
    setWelcomeNote(getDefaultWelcomeNote());
    return;
    }
    if (isEmptyObject(policy)) {
    return;
    }
    Navigation.goBack(ROUTES.WORKSPACE_INVITE.getRoute(route.params.policyID), true);
    // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
    }, []);
    useEffect(() => {
    if (isEmptyObject(invitedEmailsToAccountIDsDraft)) {
    return;
    }
    setWelcomeNote(getDefaultWelcomeNote());
    }, [getDefaultWelcomeNote, invitedEmailsToAccountIDsDraft]);

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


    • We can remove the second useEffect hook here:
      useEffect(() => {
      if (isEmptyObject(invitedEmailsToAccountIDsDraft)) {
      return;
      }
      setWelcomeNote(getDefaultWelcomeNote());
      }, [getDefaultWelcomeNote, invitedEmailsToAccountIDsDraft]);
    • And in WorkspaceInvitePage.tsx we need to clear the draft invite message when the component unmounts.

    useEffect(() => {
    return () => {
    Member.setWorkspaceInviteMembersDraft(route.params.policyID, {});
    };
    // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
    }, [route.params.policyID]);

    TO:

        useEffect(() => {
            return () => {
                Member.setWorkspaceInviteMembersDraft(route.params.policyID, {});
                Policy.setWorkspaceInviteMessageDraft(route.params.policyID, null);
            };
            // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
        }, [route.params.policyID]);
    • If we want to clear the draft message when invite members list changes, we can clear the message draft here or here.

    What alternative solutions did you explore? (Optional)

    Result

  6. Shahidullah-Muffakir commented on Sep 29, 2024

    @Shahidullah-Muffakir
    Contributor

    Proposal

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

    when a user deletes the invite message in the workspace invite process, the message reappears unexpectedly.

    What is the root cause of that problem?

    The root cause of this problem is that the component was automatically resetting the welcome message to its default value, even when the user had intentionally deleted it

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

    we should update the useEffect to add a check that skips resetting the invite message if it is already empty. This ensures that when the user deletes the message, it doesn't get reset to the default value.

    Add!welcomeNotecheck here:

    useEffect(() => {
    if (isEmptyObject(invitedEmailsToAccountIDsDraft)) {
    return;
    }

    to:

     useEffect(() => {
            if (isEmptyObject(invitedEmailsToAccountIDsDraft) || !welcomeNote) {
                return;
            }
    
    Screen.20Recording.202024-09-30.20at.203.mp4
  7. huult commented on Sep 30, 2024

    @huult
    Contributor

    Proposal

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

    Invite message comes back after deleting it

    What is the root cause of that problem?

    Since we set getDefaultWelcomeNote as a dependency of this hook, the hook is triggered every time the input's onChange event occurs

    }, [getDefaultWelcomeNote, invitedEmailsToAccountIDsDraft]);

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

    We should remove getDefaultWelcomeNote from the dependency array to avoid re-renders when the input changes.

    // .src/pages/workspace/WorkspaceInviteMessagePage.tsx#L94
        useEffect(() => {
            if (isEmptyObject(invitedEmailsToAccountIDsDraft)) {
                return;
            }
            setWelcomeNote(getDefaultWelcomeNote());
    -    }, [getDefaultWelcomeNote, invitedEmailsToAccountIDsDraft]);
    +    }, [invitedEmailsToAccountIDsDraft]);

    and We need to validate this input, if necessary, to avoid empty values ("")

    // .src/pages/workspace/WorkspaceInviteMessagePage.tsx#L119
            if (isEmptyObject(invitedEmailsToAccountIDsDraft)) {
                errorFields.welcomeMessage = translate('workspace.inviteMessage.inviteNoMembersError');
    -        }
    +        } else if (isEmptyObject(welcomeNote)) {
    +            errorFields.welcomeMessage = 'Please enter a welcome note.';
            }
    DetailsPOC
    Screen.Recording.2024-09-30.at.09.24.15.mp4
  8. removed
    DeployBlockerIndicates it should block deploying the API
    on Sep 30, 2024
  9. Gonals commented on Sep 30, 2024

    @Gonals
    Contributor

    Seems to be a frontend issue, so removing Web-E blocker

  10. dangrous commented on Sep 30, 2024

    @dangrous
    Contributor

    Yeah this was caused by PR #48660 and issue #34929 . We can just remove that new useEffect but I'm not sure what the point of it was originally, so pinged the PR authors. Thanks!

  11. rojiphil commented on Sep 30, 2024

    @rojiphil
    Contributor

    Yeah this was caused by PR #48660 and issue #34929 .

    @dangrous Yeah. Fixing an eslint error (i.e. using useOnyx instead of withOnyx) during some last-minute changes caused this issue. I think we can consider this as a separate issue. Please assign me here as I have the context.

    We can just remove that new useEffect but I'm not sure what the point of it was originally, so pinged the PR authors. Thanks!

    We need the second useEffect to ensure workspaceInviteMessageDraft is populated from the Onyx. However, an edge case got left out i.e. when the user intentionally deletes the entire welcome note in which case we should not reset.
    @Shahidullah-Muffakir proposal LGTM

  12. 62 remaining items

  13. melvin-bot commented on Oct 23, 2024

    @melvin-bot

    Current assignee @JmillsExpensify is eligible for the Bug assigner, not assigning anyone new.

  14. tgolen commented on Oct 23, 2024

    @tgolen
    Contributor

    BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

    • [@rojiphil] The PR that introduced the bug has been identified. Link to the PR:
    • [@rojiphil] 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:
    • [@rojiphil] A discussion in #expensify-bugs 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:
    • [@rojiphil] Determine if we should create a regression test for this bug.
    • [@rojiphil] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
    • [@JmillsExpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  15. reopened this on Oct 23, 2024
  16. rojiphil commented on Oct 24, 2024

    @rojiphil
    Contributor
    • [@rojiphil] The PR that introduced the bug has been identified. Link to the PR: Offending PR
    • [@rojiphil] 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: Added comment
    • [@rojiphil] A discussion in #expensify-bugs 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. Existing checklist is good enough to capture such issues.
    • [@rojiphil] Determine if we should create a regression test for this bug. : Yes. We can
    • [@rojiphil] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.

    Steps:

    1. Go to Account Settings -> Workspaces
    2. Select a workspace and go to Members->Invite new members
    3. Select a member to invite and click on Next to go to the invite message view.
    4. Delete the default welcome message text.
    5. Verify that the message text remains empty and does not come back.
  17. rojiphil commented on Oct 24, 2024

    @rojiphil
    Contributor

    @tgolen BZ Checklist done

  18. rojiphil commented on Oct 26, 2024

    @rojiphil
    Contributor

    @tgolen The payment step is completed as mentioned here.
    Can we close this issue if nothing else is pending? Thanks.

  19. tgolen commented on Oct 28, 2024

    @tgolen
    Contributor

    Yep, we should be good here now. I'll close it out. Thanks!

  20. tgolen commented on Oct 28, 2024

    @tgolen
    Contributor

    Actually, I was wrong. @JmillsExpensify this needs a regression test created and I think that's your part of the checklist.

  21. reopened this on Oct 28, 2024
  22. JmillsExpensify commented on Oct 31, 2024

    @JmillsExpensify
    Contributor

    Test created and linked above, so closing this issue.

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.DailyKSv2Engineering

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions