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-29] [HOLD #49996][$250] Update Default / Custom Workspace Invite Behavior #51096

Closed
dangrous opened this issue Oct 18, 2024 · 51 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 External Added to denote the issue can be worked on by a contributor NewFeature Something to build that is a new item.

Comments

@dangrous
Copy link
Contributor

dangrous commented Oct 18, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


cc @rojiphil coming from #49899

A pretty quick one here - we want to update the behavior for the Workspace Invite Message Page. Namely:

As long as the RHP stays open, keep the messages as edited (even if it is set to empty). And save the edited message as invite message draft only on an actual invite. Once the RHP closes without an actual invitation, discard the edited message. And when the RHP is shown again, show either the previously saved invite message draft or show the default message if no custom message is set.

Currently, we reset to the default value whenever the invite message page is shown and the message is empty. This is irrespective of whether the RHP stays open or closed.

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021847313199304724261
  • Upwork Job ID: 1847313199304724261
  • Last Price Increase: 2024-10-18
  • Automatic offers:
    • rojiphil | Contributor | 104486057
    • Krishna2323 | Contributor | 104883903
Issue OwnerCurrent Issue Owner: @garrettmknight
@dangrous dangrous added Daily KSv2 NewFeature Something to build that is a new item. labels Oct 18, 2024
Copy link

melvin-bot bot commented Oct 18, 2024

Triggered auto assignment to @anmurali (NewFeature), see https://stackoverflowteams.com/c/expensify/questions/14418#:~:text=BugZero%20process%20steps%20for%20feature%20requests for more details. Please add this Feature request to a GH project, as outlined in the SO.

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

melvin-bot bot commented Oct 18, 2024

⚠️ It looks like this issue is labelled as a New Feature but not tied to any GitHub Project. Keep in mind that all new features should be tied to GitHub Projects in order to properly track external CAP software time ⚠️

Copy link

melvin-bot bot commented Oct 18, 2024

Triggered auto assignment to Design team member for new feature review - @dannymcclain (NewFeature)

@dangrous dangrous added External Added to denote the issue can be worked on by a contributor Daily KSv2 Help Wanted Apply this label when an issue is open to proposals by contributors and removed Weekly KSv2 labels Oct 18, 2024
Copy link

melvin-bot bot commented Oct 18, 2024

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

@melvin-bot melvin-bot bot changed the title Update Default / Custom Invite Behavior [$250] Update Default / Custom Invite Behavior Oct 18, 2024
Copy link

melvin-bot bot commented Oct 18, 2024

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

@dangrous dangrous changed the title [$250] Update Default / Custom Invite Behavior [$250] Update Default / Custom Workspace Invite Behavior Oct 18, 2024
@Shahidullah-Muffakir
Copy link
Contributor

Shahidullah-Muffakir commented Oct 18, 2024

Edited by proposal-police: This proposal was edited at 2024-10-18 17:29:52 UTC.

Proposal

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

we are not saving the welcome message as draft when user send the invitation, it saved every time user edit the message.

What is the root cause of that problem?

New feature

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

I think the implemnetion is very straight forward

  1. don't update the message draft when user is changing the message, so remove this:
    onChangeText={(text: string) => {
    setWelcomeNote(text);
    debouncedSaveDraft(text);
    }}

    remove the:
    debouncedSaveDraft(text);
  2. and only save it as draft when user, send invite so removed this:
    debouncedSaveDraft(null);from sendInvitation function
    and add : debouncedSaveDraft(welcomeNote);
  3. remove the welcomeNote from the deps array of this useEffect:
    useEffect(() => {
    if (isEmptyObject(invitedEmailsToAccountIDsDraft) || !welcomeNote) {
    return;
    }
    setWelcomeNote(getDefaultWelcomeNote());
    }, [getDefaultWelcomeNote, invitedEmailsToAccountIDsDraft, welcomeNote]);

@huult
Copy link
Contributor

huult commented Oct 18, 2024

Edited by proposal-police: This proposal was edited at 2024-10-18 17:58:03 UTC.

Proposal

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

Update Default / Custom Workspace Invite Behavior

What is the root cause of that problem?

New feature

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

We need to create a new key to persist the new workspace invite message for storing the invite message when sending invites to members. We use this message in case the member is sent—close the RHP and then reopen the RHP

//.src/ONYXKEYS.ts#L470
+   WORKSPACE_INVITE_MESSAGE_PERSIST: 'workspaceInviteMessagePersist_',

Create a function to set the invite message

//.src/libs/actions/Policy/Policy.ts#L2153
+    function persistWorkspaceInviteMessage(policyID: string, message: string | null) {
+        Onyx.set(`${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MESSAGE_PERSIST}${policyID}`, message);
+    }

Update the function to get the default welcome note and call persistMessage when sending the invitation.

//.src/pages/workspace/WorkspaceInviteMessagePage.tsx#L68
const getDefaultWelcomeNote = useCallback(() => {
-        return (
-            ...
-        );
-    }, [workspaceInviteMessageDraft, policy, translate]);
+        let welcomeNote = '';
       
+        if (workspaceInviteMessageDraft) {
+            welcomeNote = workspaceInviteMessageDraft;
+        } else if (typeof workspaceInviteMessagePersist === 'string') {
+            welcomeNote = workspaceInviteMessagePersist;
+        } else if (policy?.description) {
+            welcomeNote = Parser.htmlToMarkdown(policy.description);
+        } else {
+            welcomeNote = translate('workspace.common.welcomeNote', {
+                workspaceName: policy?.name ?? '',
+            });
+        }

+        return welcomeNote;
+    }, [workspaceInviteMessageDraft, workspaceInviteMessagePersist, policy, translate]);

//.src/pages/workspace/WorkspaceInviteMessagePage.tsx#L89
    useEffect(() => {
-        if (isEmptyObject(invitedEmailsToAccountIDsDraft) || !welcomeNote) {
+        if ((typeof workspaceInviteMessagePersist !== 'string' && isEmptyObject(invitedEmailsToAccountIDsDraft)) || !welcomeNote) {  
            return;
        }
        setWelcomeNote(getDefaultWelcomeNote());
-    }, [getDefaultWelcomeNote, invitedEmailsToAccountIDsDraft, welcomeNote]);
+    }, [getDefaultWelcomeNote, invitedEmailsToAccountIDsDraft, welcomeNote, workspaceInviteMessagePersist]);

//.src/pages/workspace/WorkspaceInviteMessagePage.tsx#L99
+    const debouncedPersistWorkspaceInviteMessage = lodashDebounce((newDraft: string) => {
+        Policy.persistWorkspaceInviteMessage(route.params.policyID, newDraft);
+    });
    
//.src/pages/workspace/WorkspaceInviteMessagePage.tsx#L111
    const sendInvitation = () => {
        ...
+        debouncedPersistWorkspaceInviteMessage(welcomeNote ?? '');
        ...
    };

We need to clear the message draft when closing the RHP because it won't be used next time.

//.src/pages/workspace/WorkspaceInvitePage.tsx#L80
    useEffect(() => {
        return () => {
            Member.setWorkspaceInviteMembersDraft(route.params.policyID, {});
+            Policy.setWorkspaceInviteMessageDraft(route.params.policyID, '');
        };
        // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
    }, [route.params.policyID]);
Screen.Recording.2024-10-19.at.01.01.36.mp4

@rojiphil
Copy link
Contributor

@dangrous Don't we have to put this issue on hold until #49996 is done?
Also, can I be the C+ here since I have the context? I hope @aimane-chnaif does not mind.

@dangrous dangrous assigned rojiphil and unassigned aimane-chnaif Oct 18, 2024
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 18, 2024
@dangrous
Copy link
Contributor Author

ah yep forgot to hold it!

Copy link

melvin-bot bot commented Oct 18, 2024

📣 @rojiphil 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@dangrous dangrous added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 18, 2024
@dangrous dangrous changed the title [$250] Update Default / Custom Workspace Invite Behavior [HOLD #49996][$250] Update Default / Custom Workspace Invite Behavior Oct 18, 2024
@ChavdaSachin
Copy link
Contributor

Proposal

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

Update Default / Custom Workspace Invite Behavior

What is the root cause of that problem?

Behavior change on demand

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

This is on simpler side.....
Just reset the workspaceInviteMessageDraft when we render inviteMembersPage for the first time we already have firstRenderRef on WorkspaceInvitePage for similar applications, so this will trigger a reset each time user closes RHP and comes back to inviteMembers page.

    Policy.setWorkspaceInviteMessageDraft(route.params.policyID, 
        Parser.htmlToMarkdown(policy?.description ?? '') ||
        translate('workspace.common.welcomeNote', {
            workspaceName: policy?.name ?? '',
        })
    );

And boom....
Now we can get rid of tons of mechanism related to welcomeNote and everything will work perfectly.
For simplicity of proposal I am rather posting link to my test branch instead of posting all code diffs.
Test Branch

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.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Nov 13, 2024
Copy link

melvin-bot bot commented Nov 13, 2024

📣 @Krishna2323 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@jasperhuangg
Copy link
Contributor

Apologies for the delay, reviewed the proposal and it makes sense to me, thanks for the bump!

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Nov 14, 2024
@Krishna2323
Copy link
Contributor

@rojiphil PR ready for review^

Copy link

melvin-bot bot commented Nov 21, 2024

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Nov 22, 2024
@melvin-bot melvin-bot bot changed the title [HOLD #49996][$250] Update Default / Custom Workspace Invite Behavior [HOLD for payment 2024-11-29] [HOLD #49996][$250] Update Default / Custom Workspace Invite Behavior Nov 22, 2024
Copy link

melvin-bot bot commented Nov 22, 2024

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Nov 22, 2024
Copy link

melvin-bot bot commented Nov 22, 2024

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

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

Copy link

melvin-bot bot commented Nov 22, 2024

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

  • [@rojiphil] Please propose regression test steps to ensure the new feature will work correctly on production in further releases.
  • [@garrettmknight] 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 Nov 29, 2024
@rojiphil
Copy link
Contributor

@garrettmknight This issue is an improvement and not a bug. As such, I do not think a BZ checklist is needed here.

But, adding the following test case to the database would be ideal to avoid any regressions:

Precondition: No preexisting saved invite message draft should be set for the workspace.

  1. Go to Account Settings -> Workspaces
  2. Select a workspace and go to Members->Invite member
  3. Select a member to invite and click on Next to go to the invite message view. This will show the default welcome message.
  4. Delete the default welcome message text so that the message text is now empty.
  5. Navigate back to member selection page and click Next again to go to the invite message view
  6. Verify that the message text remains empty (Test 1)
  7. Dismiss the RHP either by navigating back twice or by clicking outside of the RHP
  8. Click on Invite member to navigate to member selection page, select a member, and click on Next to go to the invite message view.
  9. Verify that the default welcome message is displayed (Test 2).
  10. Edit the welcome message text with a custom message.
  11. Navigate back to member selection page and click Next again to go to the invite message view
  12. Verify that the the custom message is displayed (Test 3)
  13. Dismiss the RHP either by navigating back twice or by clicking outside of the RHP
  14. Click on Invite member to navigate to member selection page, select a member, and click on Next to go to the invite message view.
  15. Verify that the default welcome message is displayed (Test 4).
  16. Edit the welcome message text with a custom message.
  17. Click Invite so that invitation is sent to the member and RHP is dismissed.
  18. Click on Invite member to navigate to member selection page, select a member, and click on Next to go to the invite message view.
  19. Verify that the custom message set in Step 16 is displayed (Test 5).
  20. Delete the custom message text so that the message text is now empty.
  21. Click Invite so that invitation is sent to the member and RHP is dismissed.
  22. Click on Invite member to navigate to member selection page, select a member, and click on Next to go to the invite message view.
  23. Verify that the message text remains empty (Test 6).

@melvin-bot melvin-bot bot added the Overdue label Dec 2, 2024
Copy link

melvin-bot bot commented Dec 2, 2024

@garrettmknight, @rojiphil, @dannymcclain, @jasperhuangg, @Krishna2323 Whoops! This issue is 2 days overdue. Let's get this updated quick!

@garrettmknight
Copy link
Contributor

@rojiphil new offer out to you.

@melvin-bot melvin-bot bot removed the Overdue label Dec 2, 2024
@garrettmknight
Copy link
Contributor

@Krishna2323 you've been paid!

@rojiphil
Copy link
Contributor

rojiphil commented Dec 2, 2024

@rojiphil new offer out to you.

@garrettmknight Accepted the offer. Thanks.

@garrettmknight
Copy link
Contributor

Paid out, closing!

@github-project-automation github-project-automation bot moved this from Bugs and Follow Up Issues to Done in [#whatsnext] #expense Dec 2, 2024
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 Daily KSv2 External Added to denote the issue can be worked on by a contributor NewFeature Something to build that is a new item.
Projects
Status: Done
Development

No branches or pull requests