Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 of 6 tasks
lanitochka17 opened this issue Sep 29, 2024 · 58 comments
Closed
3 of 6 tasks
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering

Comments

@lanitochka17
Copy link

lanitochka17 commented Sep 29, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] 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): [email protected]
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
@lanitochka17 lanitochka17 added DeployBlockerCash This issue or pull request should block deployment DeployBlocker Indicates it should block deploying the API labels Sep 29, 2024
Copy link

melvin-bot bot commented Sep 29, 2024

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

Copy link
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.

@Nodebrute
Copy link
Contributor

Nodebrute commented Sep 29, 2024

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)

@Krishna2323
Copy link
Contributor

Krishna2323 commented Sep 29, 2024

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

@Shahidullah-Muffakir
Copy link
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

@huult
Copy link
Contributor

huult commented Sep 30, 2024

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.';
        }
POC
Screen.Recording.2024-09-30.at.09.24.15.mp4

@Gonals Gonals removed the DeployBlocker Indicates it should block deploying the API label Sep 30, 2024
@Gonals
Copy link
Contributor

Gonals commented Sep 30, 2024

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

@dangrous
Copy link
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!

@rojiphil
Copy link
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

@dangrous
Copy link
Contributor

Yep checking for an empty welcome note makes sense to me. Can you raise that PR quick?

@rojiphil
Copy link
Contributor

Yep checking for an empty welcome note makes sense to me. Can you raise that PR quick?

Sure. Working on the PR now. Will update in about an hour

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Hourly KSv2 labels Sep 30, 2024
@rojiphil
Copy link
Contributor

@dangrous PR is ready for review.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Sep 30, 2024
@melvin-bot melvin-bot bot changed the title Workspace - Invite message comes back after deleting it [HOLD for payment 2024-10-07] Workspace - Invite message comes back after deleting it Sep 30, 2024
@dannymcclain
Copy link
Contributor

I think you've outlined it exactly how I was understanding it. 👍

@rojiphil
Copy link
Contributor

are you up for tackling that adjustment, or should we open it up to contributors again?

@dangrous I think it’s best to open it up to contributors again to get the best proposal as this does not seem like a minor adjustment.

@dangrous
Copy link
Contributor

Okay cool! I may actually just make a new issue for it, so we can close this one out / pay. It's more of a clarification on expected behavior than a regression or anything that should be handled here.

I'm also going to hold it on #49996 which is related and should make things easier.

@dangrous
Copy link
Contributor

Made #51096!

@rojiphil
Copy link
Contributor

Okay cool! I may actually just make a new issue for it, so we can close this one out / pay.

Yeah. Since another issue is created for the enhancement, I think we can pay as per this comment and close this one out. cc @JmillsExpensify

@melvin-bot melvin-bot bot added the Overdue label Oct 21, 2024
@JmillsExpensify
Copy link

Ok, so based on that comment, we'd have:

@melvin-bot melvin-bot bot removed the Overdue label Oct 21, 2024
@JmillsExpensify
Copy link

Offers sent to both via Upwork.

@Shahidullah-Muffakir
Copy link
Contributor

Offers sent to both via Upwork.

Accepted, Thank you.

@rojiphil
Copy link
Contributor

Offers sent to both via Upwork.

Accepted the offer. Thanks

@JmillsExpensify
Copy link

Both paid out. Thank you!

@tgolen tgolen added the Bug Something is broken. Auto assigns a BugZero manager. label Oct 23, 2024
Copy link

melvin-bot bot commented Oct 23, 2024

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

@tgolen
Copy link
Contributor

tgolen commented Oct 23, 2024

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:

@tgolen tgolen reopened this Oct 23, 2024
@rojiphil
Copy link
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.

@rojiphil
Copy link
Contributor

@tgolen BZ Checklist done

@rojiphil
Copy link
Contributor

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

@tgolen
Copy link
Contributor

tgolen commented Oct 28, 2024

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

@tgolen tgolen closed this as completed Oct 28, 2024
@tgolen
Copy link
Contributor

tgolen commented Oct 28, 2024

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

@tgolen tgolen reopened this Oct 28, 2024
@melvin-bot melvin-bot bot added the Overdue label Oct 30, 2024
@JmillsExpensify
Copy link

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
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering
Projects
None yet
Development

No branches or pull requests