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-11-07] [HOLD for payment 2024-10-30] [$125.00] Workspace -Previous invite message reappears after clearing the field and entering a character #49996

Closed
2 of 6 tasks
lanitochka17 opened this issue Oct 1, 2024 · 31 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Oct 1, 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.42-0
Reproducible in staging?: Y
Reproducible in production?: Y
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. Launch New Expensify app
  2. Go to workspace settings > Members
  3. Click Invite member
  4. Select a member and proceed to invite message page
  5. Clear the invite message field
  6. Enter a character

Expected Result:

The previous invitation message will not appear after clearing the field and entering a character

Actual Result:

The previous invitation message reappears after clearing the field and entering a character

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

Bug6620980_1727778413019.ScreenRecording_10-01-2024_18-21-38_1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021842313701781491251
  • Upwork Job ID: 1842313701781491251
  • Last Price Increase: 2024-10-04
Issue OwnerCurrent Issue Owner: @adelekennedy
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 1, 2024
Copy link

melvin-bot bot commented Oct 1, 2024

Triggered auto assignment to @adelekennedy (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.

@lanitochka17
Copy link
Author

@adelekennedy FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

@lanitochka17
Copy link
Author

We think that this bug might be related to #wave-collect - Release 1

@nyomanjyotisa
Copy link
Contributor

Proposal

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

Workspace -Previous invite message reappears after clearing the field and entering a character

What is the root cause of that problem?

The root cause of this problem stems from the interaction between the defaultValue and value props. The defaultValue prop is used to set the initial value of the input. While this works for the first load of the component, it introduces an issue when the user clears the input and entering a character on android

defaultValue={getDefaultWelcomeNote()}
value={welcomeNote}

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

We should either remove the defaultValue or value props, and use only one of it

What alternative solutions did you explore? (Optional)

@kushu7
Copy link
Contributor

kushu7 commented Oct 1, 2024

Edited by proposal-police: This proposal was edited at 2024-10-01 14:39:43 UTC.

Proposal

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

Previous invite message reappears after clearing the field due to re-render

What is the root cause of that problem?

It is happening because we have workspaceInviteMessageDraft in deps array of callback function and this gets update on onChange of input.

const getDefaultWelcomeNote = useCallback(() => {
return (
// workspaceInviteMessageDraft can be an empty string
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
workspaceInviteMessageDraft ||
// policy?.description can be an empty string
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
Parser.htmlToMarkdown(policy?.description ?? '') ||
translate('workspace.common.welcomeNote', {
workspaceName: policy?.name ?? '',
})
);
}, [workspaceInviteMessageDraft, policy, translate]);

which is causing this useEffect to run on each render and setting back to default message as when workspaceInviteMessageDraft is empty

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

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

By removing workspaceInviteMessageDraft from here will fix the issue
as we want getDefaultMessage on first render only. we can safely remove it.

}, [workspaceInviteMessageDraft, policy, translate]);

What alternative solutions did you explore? (Optional)

None

@huult
Copy link
Contributor

huult commented Oct 1, 2024

Edited by proposal-police: This proposal was edited at 2024-10-01 14:54:15 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?

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

}, [getDefaultWelcomeNote, invitedEmailsToAccountIDsDraft, welcomeNote]);

When we remove all the text and input new text, setWelcomeNote will be triggered.

setWelcomeNote(getDefaultWelcomeNote());

and workspaceInviteMessageDraft is not saving completely, so it gets the default value, and this issue occurs

workspaceInviteMessageDraft ||

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) || !welcomeNote) {
+        if (isEmptyObject(invitedEmailsToAccountIDsDraft)) {
            return;
        }
        setWelcomeNote(getDefaultWelcomeNote());
-    }, [getDefaultWelcomeNote, invitedEmailsToAccountIDsDraft, welcomeNote]);
+    }, [invitedEmailsToAccountIDsDraft]);

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

// .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-10-01.at.21.25.03.mov

@bernhardoj
Copy link
Contributor

Proposal

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

The default message shows briefly everytime we type in the ws invite message page.

What is the root cause of that problem?

We have this effect which updates the welcome note to the default every time the welcome note is updated.

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

This is added in #48660 because we migrated to useOnyx so when the component is mounted for the first time, workspaceInviteMessageDraft from Onyx is initially undefined, so getDefaultWelcomeNote will return the default message instead of the saved user draft,

const getDefaultWelcomeNote = useCallback(() => {
return (
// workspaceInviteMessageDraft can be an empty string
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
workspaceInviteMessageDraft ||
// policy?.description can be an empty string
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
Parser.htmlToMarkdown(policy?.description ?? '') ||
translate('workspace.common.welcomeNote', {
workspaceName: policy?.name ?? '',
})
);

and is set as the input default value.

defaultValue={getDefaultWelcomeNote()}

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

Remove this useEffect

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

and instead, to overcome the issue after migrating to useOnyx, we can re-trigger this effect when the workspaceInviteMessageDraft is loaded.

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
}, []);

const [workspaceInviteMessageDraft, workspaceInviteMessageDraftResult] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MESSAGE_DRAFT}${route.params.policyID.toString()}`);
const isWorkspaceInviteMessageDraftLoading = isLoadingOnyxValue(workspaceInviteMessageDraftResult);

useEffect(() => {
    if (isWorkspaceInviteMessageDraftLoading) {
        return;
    }
    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
}, [isWorkspaceInviteMessageDraftLoading]);

We can consider removing the defaultValue too

defaultValue={getDefaultWelcomeNote()}

we can optionally returning null when isWorkspaceInviteMessageDraftLoading is true

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

melvin-bot bot commented Oct 4, 2024

@adelekennedy Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@adelekennedy
Copy link

adelekennedy commented Oct 4, 2024

I can replicate this but it's so briefI think it's really a polish - updating price

@melvin-bot melvin-bot bot removed the Overdue label Oct 4, 2024
@adelekennedy adelekennedy added the External Added to denote the issue can be worked on by a contributor label Oct 4, 2024
@melvin-bot melvin-bot bot changed the title Workspace -Previous invite message reappears after clearing the field and entering a character [$250] Workspace -Previous invite message reappears after clearing the field and entering a character Oct 4, 2024
Copy link

melvin-bot bot commented Oct 4, 2024

Job added to Upwork: https://www.upwork.com/jobs/~021842313701781491251

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 4, 2024
Copy link

melvin-bot bot commented Oct 4, 2024

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

@adelekennedy adelekennedy changed the title [$250] Workspace -Previous invite message reappears after clearing the field and entering a character [$62.50] Workspace -Previous invite message reappears after clearing the field and entering a character Oct 4, 2024
Copy link

melvin-bot bot commented Oct 8, 2024

@abdulrahuman5196, @adelekennedy Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot added the Overdue label Oct 8, 2024
@adelekennedy
Copy link

@abdulrahuman5196 a few proposals to review above!

@abdulrahuman5196
Copy link
Contributor

@bernhardoj 's proposal here #49996 (comment) looks good and works well. It addresses the root cause and solution where we don't need to update the defaultWelcomeNote whenever there is a welcomeNote change compared to other proposals.

🎀 👀 🎀
C+ Reviewed

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

melvin-bot bot commented Oct 9, 2024

Triggered auto assignment to @dangrous, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@abdulrahuman5196
Copy link
Contributor

@adelekennedy IMO, this could be lesser bug compared to other normal bugs, but reduced price of 4 times than normal bug seems little undervalued comparing to any normal bug.

@bernhardoj
Copy link
Contributor

@abdulrahuman5196 just a reminder to check this follow-up PR

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 23, 2024
@melvin-bot melvin-bot bot changed the title [$62.50] Workspace -Previous invite message reappears after clearing the field and entering a character [HOLD for payment 2024-10-30] [$62.50] Workspace -Previous invite message reappears after clearing the field and entering a character Oct 23, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 23, 2024
Copy link

melvin-bot bot commented Oct 23, 2024

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

Copy link

melvin-bot bot commented Oct 23, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.52-5 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 2024-10-30. 🎊

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

Copy link

melvin-bot bot 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:

  • [@abdulrahuman5196] The PR that introduced the bug has been identified. Link to the PR:
  • [@abdulrahuman5196] 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:
  • [@abdulrahuman5196] 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:
  • [@abdulrahuman5196] Determine if we should create a regression test for this bug.
  • [@abdulrahuman5196] 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.
  • [@adelekennedy] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Oct 29, 2024
Copy link

melvin-bot bot commented Oct 30, 2024

Payment Summary

Upwork Job

BugZero Checklist (@adelekennedy)

  • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1842313701781491251/hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Oct 31, 2024
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2024-10-30] [$62.50] Workspace -Previous invite message reappears after clearing the field and entering a character [HOLD for payment 2024-11-07] [HOLD for payment 2024-10-30] [$62.50] Workspace -Previous invite message reappears after clearing the field and entering a character Oct 31, 2024
Copy link

melvin-bot bot commented Oct 31, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.55-10 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 2024-11-07. 🎊

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

Copy link

melvin-bot bot commented Oct 31, 2024

@abdulrahuman5196 @adelekennedy 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]

@adelekennedy
Copy link

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
  • 2b. Reported on staging (deploy blocker)
  • 2c. 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:

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

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

Test:

Do we agree 👍 or 👎

@abdulrahuman5196
Copy link
Contributor

abdulrahuman5196 commented Nov 11, 2024

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
  • 2b. Reported on staging (deploy blocker)
  • 2c. 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/48660/files#r1836833752

  • [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: N/A

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

Test:

  1. Open workspace members invite page
  2. Select any user and press next to the invite message page
  3. Clears the invite message page
  4. Type any characters
  5. Verify the previous message doesn't show briefly on every type

Do we agree 👍 or 👎

@adelekennedy

@adelekennedy adelekennedy changed the title [HOLD for payment 2024-11-07] [HOLD for payment 2024-10-30] [$62.50] Workspace -Previous invite message reappears after clearing the field and entering a character [HOLD for payment 2024-11-07] [HOLD for payment 2024-10-30] [$125.00] Workspace -Previous invite message reappears after clearing the field and entering a character Nov 12, 2024
@adelekennedy
Copy link

adelekennedy commented Nov 12, 2024

reviewing the issue I'm updating the price to $125

Payouts due:

@bernhardoj
Copy link
Contributor

Thanks!

Requested in ND.

@JmillsExpensify
Copy link

$125 approved for @bernhardoj

@JmillsExpensify
Copy link

$125 approved for @abdulrahuman5196

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. External Added to denote the issue can be worked on by a contributor Weekly KSv2
Projects
No open projects
Status: Polish
Development

No branches or pull requests

9 participants