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 2023-07-26] [$1000] Web - Chat - Inconsistent behaviour while entering emails in chat #20085

Closed
1 of 6 tasks
kbecciv opened this issue Jun 2, 2023 · 53 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

@kbecciv
Copy link

kbecciv commented Jun 2, 2023

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


Action Performed:

  1. Login to ND
  2. Click on any chat
  3. Send [email protected]@gmail.com
  4. Send [email protected]@gmail.com

Expected Result:

The formatting in first message is similar to the 2nd message or vice versa

Actual Result:

Behaviour is inconsistent

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.22.0

Reproducible in staging?: yes

Reproducible in production?: yes

If this was caught during regression testing, add the test name, ID and link from TestRail:

Email or phone of affected tester (no customers):

Logs: https://stackoverflow.com/c/expensify/questions/4856

Notes/Photos/Videos: Any additional supporting documentation

image (51)

Recording.2949.mp4

Expensify/Expensify Issue URL:

Issue reported by: @aman-atg

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1684776832487869

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01d7534e113b95a39f
  • Upwork Job ID: 1667290768145391616
  • Last Price Increase: 2023-06-09
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 2, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 2, 2023

Triggered auto assignment to @alexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Jun 2, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@alexpensify
Copy link
Contributor

I'll test soon

@tienifr
Copy link
Contributor

tienifr commented Jun 3, 2023

Proposal

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

When sending emails in chat, it may display inconsistently as a mention or as an email.

What is the root cause of that problem?

Let's look at the replace rules from ExpensiMark.js in the expensify-common package.

The current replace logic is prioritizing replacing userMentions to autoEmail. While both [email protected]@gmail.com and [email protected]@gmail.com match the userMentions rule, only the latter is considered valid by the isValidMention() function since it starts with @. The invalid one (starting with a character t) is then replaced with the autoEmail rule.

image

Because of this, [email protected]@gmail.com is being rendered with email link, and [email protected]@gmail.com is being rendered with mention.

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

IMO, we should display the texts as emails instead of mentions. It can be achieved by moving the autoEmail rule to before the userMentions and hereMentions rule. This ensures that the email will always be replaced first, then if no email matches then it should be replaced with mentions.

What alternative solutions did you explore? (Optional)

Alternatively, we could prioritize rendering the texts as mentions by changing the userMentions rule. Something like this would work

            {
                name: 'userMentions',
                regex: new RegExp(`([\`.a-zA-Z])?(@+${CONST.REG_EXP.EMAIL_PART})(?![^<]*(<\\/pre>|<\\/code>|<\\/a>))`, 'gm'),
                replacement: (match, g1, g2) => {
                    if (!Str.isValidMention(g2)) {
                        return match;
                    }
                    return `${g1 || ''}<mention-user>${g2}</mention-user>`;
                },
            },

Another way is that although I'm not aware of the context of why it should be there, we could remove the [\'.a-zA-Z]? part from the mention pattern so that it can match all texts that start with @ and follow by an email address.

Result

Working well after the fixes

Rendered as email
Screen.Recording.2023-06-03.at.15.59.08.mov
Rendered as mention
Screen.Recording.2023-06-03.at.16.13.05.1.mov

@alexpensify
Copy link
Contributor

I'll test tomorrow

@melvin-bot melvin-bot bot added the Overdue label Jun 6, 2023
@alexpensify
Copy link
Contributor

@kbecciv - could you please double-check if this is happening on other platforms?

I tested in Chrome like the GH suggested:

image

I noticed that the issue happens in MacOS/Desktop too:

image

Thanks!

@melvin-bot melvin-bot bot removed the Overdue label Jun 6, 2023
@alexpensify
Copy link
Contributor

@kbecciv any news here? Thank you!

@alexpensify alexpensify added the External Added to denote the issue can be worked on by a contributor label Jun 9, 2023
@melvin-bot melvin-bot bot changed the title Web - Chat - Inconsistent behaviour while entering emails in chat [$1000] Web - Chat - Inconsistent behaviour while entering emails in chat Jun 9, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 9, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jun 9, 2023

Current assignee @alexpensify is eligible for the External assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented Jun 9, 2023

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jun 9, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 9, 2023

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

@alexpensify
Copy link
Contributor

Waiting for proposals

@s-alves10
Copy link
Contributor

s-alves10 commented Jun 12, 2023

Proposal

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

When sending emails in chat, it is parsed inconsistently.

What is the root cause of that problem?

Here is the user-mention regex
https://github.com/Expensify/expensify-common/blob/743108fd2428945c5a75baa2a027b5a4ab407b5b/lib/ExpensiMark.js#L111-L120

test+1@[email protected] is parsed as user-mention while test@[email protected] isn't parsed.

    [email protected]@gmail.com => test+1<user-mention>@[email protected]</user-mention>
    [email protected]@gmail.com => [email protected]@gmail.com

This result is passed to the autoEmail rule. @[email protected] isn't parsed as email while [email protected] is parsed as valid email.
That's why the latter is parsed as email, the former is parsed as mention

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

I think both should be parsed as email. In order to do that We need to change the user-mention rule.

    {
        name: 'userMentions',
        regex: new RegExp(`((?:(?:\\W)|^)(_?))@${CONST.REG_EXP.EMAIL_PART}(\\2)(?![^<]*(<\\/pre>|<\\/code>|<\\/a>))`, 'gm'),
        replacement: (match, g1, g2, g3, g4) => {
            if (!Str.isValidMention(match)) {
                return match;
            }
            return `${g1}<mention-user>@${g3}</mention-user>${g4}`;
        },
    },

This works as expected and passed all existing tests.

The following is the manual test result.

    @[email protected]  ===>  <mention-user>@[email protected]</mention-user>
    _@[email protected]  ===>  _@[email protected]
    _@[email protected]_  ===>  _<mention-user>@[email protected]</mention-user>_
    ~@[email protected]  ===>  ~<mention-user>@[email protected]</mention-user>
    ~@[email protected]~  ===>  ~<mention-user>@[email protected]</mention-user>~
    *@[email protected]  ===>  *<mention-user>@[email protected]</mention-user>
    *@[email protected]*  ===>  *<mention-user>@[email protected]</mention-user>*
    [email protected]@gmail.com  ===>  [email protected]@gmail.com
    test@@[email protected]  ===>  test@<mention-user>@[email protected]</mention-user>
    [email protected]@gmail.com  ===>  [email protected]@gmail.com
    test+1@@[email protected]  ===>  test+1@<mention-user>@[email protected]</mention-user>
    [email protected]@gmail.com  ===>  [email protected]@gmail.com
    [email protected]@gmail.com_  ===>  [email protected]@gmail.com_
    test*@[email protected]  ===>  test*<mention-user>@[email protected]</mention-user>
    test*@[email protected]*  ===>  test*<mention-user>@[email protected]</mention-user>*
    test#@[email protected]  ===>  test#<mention-user>@[email protected]</mention-user>
    test"@[email protected]  ===>  test"<mention-user>@[email protected]</mention-user>
    test'@[email protected]  ===>  test'<mention-user>@[email protected]</mention-user>
    @@[email protected]  ===>  @<mention-user>@[email protected]</mention-user>
    _@@[email protected]  ===>  _@<mention-user>@[email protected]</mention-user>
    #@@[email protected]  ===>  #@<mention-user>@[email protected]</mention-user>
    '@@[email protected]  ===>  '@<mention-user>@[email protected]</mention-user>
    @@@@[email protected]  ===>  @@@<mention-user>@[email protected]</mention-user>

This solution will fix the #19997 as well.

Result
20085_mac_chrome.mp4

What alternative solutions did you explore? (Optional)

@alexpensify
Copy link
Contributor

@eVoloshchak - when you get a chance, can you review the latest proposal? Thanks!

@jeet-dhandha
Copy link
Contributor

jeet-dhandha commented Jun 15, 2023

@eVoloshchak I have a question:

  1. What are we expecting this text to be parsed as email or mention ?
  2. Based on what we decide then we need to fix the issue.

We should also be test with below texts:

@eVoloshchak
Copy link
Contributor

@jeet-dhandha

What are we expecting this text to be parsed as email or mention ?

As email. Both don't start with @, there shouldn't be a mention mid-word, mention should always start with a space/new line

test@[email protected]
test+1@[email protected]

These two should also be rendered as emails (the same as they are rendered here on GitHub)

@eVoloshchak
Copy link
Contributor

I think mention should always start with a space/new line, so we should render all of these as emails (same as Github does on this page).
@tienifr's proposal looks good to me

we should display the texts as emails instead of mentions. It can be achieved by moving the autoEmail rule to before the userMentions and hereMentions rule. This ensures that the email will always be replaced first, then if no email matches then it should be replaced with mentions.

I completely agree with this. We should test with test@[email protected] and test+1@[email protected], since, as @jeet-dhandha pointed out those are also rendered incorrectly. @tienifr, we should have a couple of tests to ensure this isn't broken in the future

🎀👀🎀 C+ reviewed!
cc: @yuwenmemon

@alexpensify alexpensify removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jun 15, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 15, 2023

📣 @tienifr You have been assigned to this job by @alexpensify!
Please apply to this job in Upwork 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 📖

@tienifr
Copy link
Contributor

tienifr commented Jul 14, 2023

The PR to update expensify-common is ready for review!

cc @eVoloshchak @alexpensify

@alexpensify
Copy link
Contributor

Awesome, looks like the PR is moving along.

@alexpensify
Copy link
Contributor

PR was approved

@melvin-bot
Copy link

melvin-bot bot commented Jul 17, 2023

Based on my calculations, the pull request did not get merged within 3 working days of assignment. Please, check out my computations here:

  • when @tienifr got assigned: 2023-06-15 23:20:47 Z
  • when the PR got merged: 2023-07-17 17:41:01 UTC
  • days elapsed: 21

On to the next one 🚀

@alexpensify
Copy link
Contributor

Alright, waiting for automation to kick in here.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Jul 19, 2023
@melvin-bot melvin-bot bot changed the title [$1000] Web - Chat - Inconsistent behaviour while entering emails in chat [HOLD for payment 2023-07-26] [$1000] Web - Chat - Inconsistent behaviour while entering emails in chat Jul 19, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 19, 2023

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, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 19, 2023

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

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Jul 19, 2023

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:

  • [@eVoloshchak] The PR that introduced the bug has been identified. Link to the PR:
  • [@eVoloshchak] 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:
  • [@eVoloshchak] 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:
  • [@eVoloshchak] Determine if we should create a regression test for this bug.
  • [@eVoloshchak] 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.
  • [@alexpensify] 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 Overdue and removed Weekly KSv2 labels Jul 25, 2023
@alexpensify
Copy link
Contributor

@eVoloshchak when you get a chance, can you please complete the checklist?

I'll be working on the payment process tomorrow.

@eVoloshchak
Copy link
Contributor

@alexpensify
Copy link
Contributor

alexpensify commented Jul 26, 2023

Here is the payment summary:

  • External issue reporter - @aman-atg $250
  • Contributor that fixed the issue - @tienifr $1000
  • Contributor+ that helped on the issue and/or PR - @eVoloshchak $1000

Upwork Job: https://www.upwork.com/jobs/~0152cd2b837df9a9df

*If applicable, the bonuses will be applied on the final payment

Extra Notes regarding payment: This one was held because of the merge freeze, so I believe there is still a payment here. With that said, there will be no urgency bonus.

@alexpensify
Copy link
Contributor

I'm having trouble with the Upwork job and will complete the process tomorrow.

@eVoloshchak
Copy link
Contributor

Requested the payment via NewDot

@JmillsExpensify
Copy link

Reviewed details for @eVoloshchak. This is accurate and approved for payment in NewDot.

@alexpensify
Copy link
Contributor

@aman-atg and @tienifr - I've sent the payment via Upwork, please accept and I can complete the process. Thanks!

@aman-atg
Copy link
Contributor

@alexpensify I've accepted the offer on Upwork, Thanks.

@alexpensify
Copy link
Contributor

Closing - I've paid @aman-atg and @tienifr via Upwork and I closed the job there too.

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
None yet
Development

No branches or pull requests

10 participants