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

Workspace - Invite message comes back after deleting it #49899

Open
3 of 6 tasks
lanitochka17 opened this issue Sep 29, 2024 · 12 comments
Open
3 of 6 tasks

Workspace - Invite message comes back after deleting it #49899

lanitochka17 opened this issue Sep 29, 2024 · 12 comments
Assignees
Labels
DeployBlockerCash This issue or pull request should block deployment Engineering Reviewing Has a PR in review Weekly KSv2

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DeployBlockerCash This issue or pull request should block deployment Engineering Reviewing Has a PR in review Weekly KSv2
Projects
None yet
Development

No branches or pull requests

8 participants