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-07-26] [$250] Android - Workspace- WS invite message shows html message briefly #42668

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

Comments

@lanitochka17
Copy link

lanitochka17 commented May 27, 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: 1.4.76
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4578418
Issue reported by: Applause - Internal Team

Action Performed:

  1. Launch app
  2. Tap profile -- workspaces -- workspace
  3. Tap members -- invite member
  4. Select a user and tap next
  5. Tap app's back button
  6. Tap next

Expected Result:

Workspace invite message must not show html message briefly

Actual Result:

Workspace invite message shows html message briefly

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

Bug6493310_1716840390127.Screenrecorder-2024-05-28-01-32-48-899_compress_1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01b2c0cb41c6778335
  • Upwork Job ID: 1796503664094650368
  • Last Price Increase: 2024-06-28
  • Automatic offers:
    • mkhutornyi | Reviewer | 102917575
    • bernhardoj | Contributor | 102917576
Issue OwnerCurrent Issue Owner: @mkhutornyi
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels May 27, 2024
Copy link

melvin-bot bot commented May 27, 2024

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

@sonialiap 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 #vip-vsp

@neonbhai
Copy link
Contributor

Proposal

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

WS invite message shows html message briefly

What is the root cause of that problem?

We don't parse to Markdown when setting default value here:

defaultValue={getDefaultWelcomeNote()}

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

We should call the parser when setting default value:

defaultValue={parser.htmlToMarkdown(getDefaultWelcomeNote())}

@allgandalf
Copy link
Contributor

allgandalf commented May 27, 2024

Proposal

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

We see html input for a second for invite messages.

What is the root cause of that problem?

When the RHP renders for the first time, we get the default message from getDefaultWelcomeNote:

const getDefaultWelcomeNote = () =>

This will set the welcome message to:

parser.replace(
translate('workspace.common.welcomeNote', {
workspaceName: policy?.name ?? '',
}),
);

Screenshot 2024-05-28 at 3 49 11 AM

Here we get the content with HTML tags.

Now, we also have a useEffect in place, which will again set the state of welcomeNote using setWelcomeNote:

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

Here we have used htmlToMarkdown, this will render the HTML to markdown.

Hence we only see html message for a split second and then we see markdown content, this is the root cause.

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

We should update getDefaultWelcomeNote to use parser.htmlToMarkdown instead of parser.replace:

--- a/src/pages/workspace/WorkspaceInviteMessagePage.tsx
+++ b/src/pages/workspace/WorkspaceInviteMessagePage.tsx
@@ -86,12 +86,17 @@ function WorkspaceInviteMessagePage({
         // policy?.description can be an empty string
         // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
         policy?.description ||
-        parser.replace(
+        parser.htmlToMarkdown(
             translate('workspace.common.welcomeNote', {
                 workspaceName: policy?.name ?? '',
             }),
         );

This way we parse the default welcome message from the first time itself.

What alternative solutions did you explore? (Optional)

If parser.replace is required here, then we can instead first do parser.replace and then wrap the result in parser.htmlToMarkdown:

--- a/src/pages/workspace/WorkspaceInviteMessagePage.tsx
+++ b/src/pages/workspace/WorkspaceInviteMessagePage.tsx
@@ -86,12 +86,11 @@ function WorkspaceInviteMessagePage({
         // policy?.description can be an empty string
         // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
         policy?.description ||
-        parser.replace(
+        parser.htmlToMarkdown(parser.replace(
             translate('workspace.common.welcomeNote', {
                 workspaceName: policy?.name ?? '',
             }),
-        );

@bernhardoj
Copy link
Contributor

Proposal

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

WS invite message page shows a message with HTML briefly.

What is the root cause of that problem?

The initial value of welcomeNote is empty, so it will use the defaultValue.

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

The default value will take the workspace.common.welcomeNote translation and convert it to HTML (replace).

const getDefaultWelcomeNote = () =>
// 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
policy?.description ||
parser.replace(
translate('workspace.common.welcomeNote', {
workspaceName: policy?.name ?? '',
}),
);

App/src/languages/en.ts

Lines 1924 to 1925 in 2514f29

welcomeNote: ({workspaceName}: WelcomeNoteParams) =>
`You have been invited to ${workspaceName || 'a workspace'}! Download the Expensify mobile app at use.expensify.com/download to start tracking your expenses.`,

Then, this useEffect that is triggered on mount will update the welcomeNote state by taking the default value HTML and convert it to markdown.

useEffect(() => {
if (!isEmptyObject(invitedEmailsToAccountIDsDraft)) {
setWelcomeNote(parser.htmlToMarkdown(getDefaultWelcomeNote()));

That's why we see the HTML form briefly before the markdown.

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

The only markdown in the default welcome note is the link and possibly the workspace name (if the workspace name contains a markdown),

App/src/languages/en.ts

Lines 1924 to 1925 in 2514f29

welcomeNote: ({workspaceName}: WelcomeNoteParams) =>
`You have been invited to ${workspaceName || 'a workspace'}! Download the Expensify mobile app at use.expensify.com/download to start tracking your expenses.`,

and I don't think it's necessary to convert it to HTML and then back to markdown just to make the link shown as
[use.expensify.com/download](https://use.expensify.com/download).

The ExpensiMark already has an auto link rule that will convert use.expensify.com/download to a link.

Also, let's say the workspace name is b, if we call replace and htmlToMarkdown, it will just become b again, so it does nothing.

So, I would prefer to remove the replace and htmlToMarkdown logic to keep it simple.

@melvin-bot melvin-bot bot added the Overdue label May 29, 2024
@sonialiap sonialiap added the Help Wanted Apply this label when an issue is open to proposals by contributors label May 30, 2024
@sonialiap
Copy link
Contributor

Sounds buggy to me. Adding help wanted

@allgandalf
Copy link
Contributor

@sonialiap I think we should add external label for C+ assignment, help wanted didn’t trigger auto assignment

@sonialiap sonialiap added the External Added to denote the issue can be worked on by a contributor label May 31, 2024
@melvin-bot melvin-bot bot changed the title Android - Workspace- WS invite message shows html message briefly [$250] Android - Workspace- WS invite message shows html message briefly May 31, 2024
Copy link

melvin-bot bot commented May 31, 2024

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

Copy link

melvin-bot bot commented May 31, 2024

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

@sonialiap
Copy link
Contributor

Thanks for the catch! Adding External, hopefully automation runs this time

Copy link

melvin-bot bot commented Jun 3, 2024

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

@mkhutornyi
Copy link
Contributor

reviewing proposals

@mkhutornyi
Copy link
Contributor

@bernhardoj please make sure that your solution doesn't cause regression by checking email and sms (for phone user) and verifying that link is correctly shown.

@mkhutornyi
Copy link
Contributor

It would be good to add offending PR in root cause. This should be recent regression.

@allgandalf
Copy link
Contributor

@mkhutornyi do you have feedback on my proposal? or does it not solve the issue at core ? 🙃

@mkhutornyi
Copy link
Contributor

@allgandalf thanks for the proposal. Can you please add the reason why this happens only on native in root cause?
And same feedback above.

@bernhardoj
Copy link
Contributor

@mkhutornyi the welcome note passed to the BE is the same before and after my proposal.

<h1>bernhard josephus 2 invited you to Bernhard.josephus+9999&#x27;s Workspace 12</h1><br />You have been invited to Bernhard.josephus+9999&#x27;s Workspace 12! Download the Expensify mobile app at <a href="https://use.expensify.com/download" target="_blank" rel="noreferrer noopener">use.expensify.com/download</a> to start tracking your expenses.

Both [use.expensify.com/download](https://use.expensify.com/download) and use.expensify.com/download is converted to <a href="https://use.expensify.com/download" target="_blank" rel="noreferrer noopener">use.expensify.com/download</a> HTML, so nothing is changed.

I haven't received the invitation email, but because the data sent to the BE is identical, I assume the email body text will be identical too

@mkhutornyi
Copy link
Contributor

mkhutornyi commented Jun 6, 2024

I haven't received the invitation email

Same to me so not able to confirm email body.

@bernhardoj why do you think this happens only on native?

@bernhardoj
Copy link
Contributor

I believe that's simply because the web perf is faster. You can put a delay here and notice the issue on web too.

if (!isEmptyObject(invitedEmailsToAccountIDsDraft)) {
setWelcomeNote(parser.htmlToMarkdown(getDefaultWelcomeNote()));
return;
}

@roryabraham
Copy link
Contributor

PR merged

@roryabraham roryabraham removed the Reviewing Has a PR in review label Jul 17, 2024
@melvin-bot melvin-bot bot added the Overdue label Jul 17, 2024
@mkhutornyi
Copy link
Contributor

Not overdue

Copy link

melvin-bot bot commented Jul 19, 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.

@bernhardoj
Copy link
Contributor

A new PR to address #45740 is up

cc: @mkhutornyi

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jul 19, 2024
@melvin-bot melvin-bot bot changed the title [$250] Android - Workspace- WS invite message shows html message briefly [HOLD for payment 2024-07-26] [$250] Android - Workspace- WS invite message shows html message briefly Jul 19, 2024
Copy link

melvin-bot bot commented Jul 19, 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 Jul 19, 2024
Copy link

melvin-bot bot commented Jul 19, 2024

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

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

Copy link

melvin-bot bot commented Jul 19, 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:

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

@allgandalf
Copy link
Contributor

@mkhutornyi @roryabraham I think i am also eligible for payment here, the PR which was CP'ed to staging used solution from my proposal. So i think i might be eligible here.

@bernhardoj @mkhutornyi do correct me if that is otherwise, i just observed the same solution being used in the follow up PR to @bernhardoj's main solution, thanks :)

@mkhutornyi
Copy link
Contributor

@allgandalf please check code diff carefully. It's not same.

@allgandalf
Copy link
Contributor

opps, my bad, that was almost identical, sorry about that, thanks for clarifying though

@sonialiap
Copy link
Contributor

Payment summary:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jul 26, 2024
@mkhutornyi
Copy link
Contributor

This was caught during regression testing: https://expensify.testrail.io/index.php?/tests/view/4578418

@sonialiap
Copy link
Contributor

Thanks Mykhailo 🎉

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

No branches or pull requests

8 participants