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-06-21] [$1000] Chat - Italic _@here_ is not displayed as mention #19857

Closed
3 of 6 tasks
kbecciv opened this issue May 30, 2023 · 49 comments
Closed
3 of 6 tasks
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 May 30, 2023

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


Issue found when executing PR #19610

Action Performed:

  1. Go to NewDot
  2. Open any chat
  3. Type _@here_ and send

Expected Result:

@here should be displayed as mention (and italic)

Actual Result:

@here is displayed as italic text, no mention

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

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

https://platform.applause.com/services/links/v1/external/b2bad9b73d47f0eef1ff081f07bd1016aee711c6236b656eabc7617f11b1cbcd

Screenshot 2023-05-31 at 17 31 14

Expensify/Expensify Issue URL:

Issue reported by: @bernhardoj

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

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~019d06a47c69e1d4cd
  • Upwork Job ID: 1663843746285133824
  • Last Price Increase: 2023-05-31
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels May 30, 2023
@melvin-bot
Copy link

melvin-bot bot commented May 30, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented May 30, 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

@sethraj14
Copy link

@kbecciv It is showing like this, the expected behaviour is italic @here, can you confirm this ?

Screenshot 2023-05-31 at 3 52 21 AM

@conorpendergrast
Copy link
Contributor

@sethraj14 When you enter:
_@here_
the expectation is that you see 1) a mention (for @here) and 2) in italics

@conorpendergrast
Copy link
Contributor

Compare
_@here_
with
_@[email protected]_

image

@conorpendergrast conorpendergrast added the External Added to denote the issue can be worked on by a contributor label May 31, 2023
@melvin-bot melvin-bot bot changed the title Chat - Italic '@here' is not displayed as mention [$1000] Chat - Italic '@here' is not displayed as mention May 31, 2023
@melvin-bot
Copy link

melvin-bot bot commented May 31, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented May 31, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented May 31, 2023

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

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

melvin-bot bot commented May 31, 2023

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

@conorpendergrast conorpendergrast changed the title [$1000] Chat - Italic '@here' is not displayed as mention [$1000] Chat - Italic @here is not displayed as mention May 31, 2023
@conorpendergrast conorpendergrast changed the title [$1000] Chat - Italic @here is not displayed as mention [$1000] Chat - Italic _@here_ is not displayed as mention May 31, 2023
@bernhardoj
Copy link
Contributor

@kbecciv can you add me as the reporter too (based on my report here), please? Thanks!

@dummy-1111
Copy link
Contributor

dummy-1111 commented May 31, 2023

Proposal

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

Italic _@here_ is not displayed as mention.

What is the root cause of that problem?

Now hereMention rule is applied before italic rule. Current regexp is as follows.

   regex: /[`.a-zA-Z]?@here\b(?![^<]*(<\/pre>|<\/code>|<\/a>))/gm,

We use \b in order to match @hero word, that is, @here needs to be followed by space character.
But _ is considered as a word character and doesn't match. This is the root cause.

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

Including _ optionally before and after @here would solve the issue successfully.

   regex: /[`.a-zA-Z0-9]?(_?)@here\1\b(?![^<]*(<\/pre>|<\/code>|<\/a>))/gm,

image

Result
mac_chrome_19857.mp4

What alternative solutions did you explore? (Optional)

@getusha
Copy link
Contributor

getusha commented May 31, 2023

Proposal

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

italics styling is not applied to @here mention

What is the root cause of that problem?

Currently we have a regex to detect both user and here mention in expensify-common

            {
                name: 'hereMentions',
                regex: /[`.a-zA-Z]?@here\b(?![^<]*(<\/pre>|<\/code>|<\/a>))/gm,
                replacement: (match) => {
                    if (!Str.isValidMention(match)) {
                        return match;
                    }
                    return `<mention-here>${match}</mention-here>`;
                },
            },

The \b in a regex is a word boundary anchor, which matches at the position between a word character and a non-word character. A word character typically includes alphanumeric characters (letters and digits) and underscores, but it does not include special characters or whitespace.

so if there is underscore and alphanumeric character right after the @here match it will discard the match.

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

We should update the hereMentions regex to

/[`.a-zA-Z]?@here(?![^<_\s]*(<\/pre>|<\/code>|<\/a>|[a-zA-Z]))/gm
  1. Remove \b
  2. [^<_\s] to match if the consecutive character is _ and space
  3. |[a-zA-Z] after the removal of \b the match will not be discarded if the consecutive character is alphanumeric then this will insure to not match invalid @here mentions like @herehi. adding 0-9 inside it will also prevent matching invalid mention like @here1212

Result

Screenshot 2023-05-31 at 6 28 04 PM Screenshot 2023-05-31 at 6 27 22 PM

What alternative solutions did you explore? (Optional)

@eh2077
Copy link
Contributor

eh2077 commented Jun 1, 2023

Proposal

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

Italic _@here_ is not displayed as mention.

What is the root cause of that problem?

The root cause of this issue is from the regex of here mention

/[`.a-zA-Z]?@here\b(?![^<]*(<\/pre>|<\/code>|<\/a>))/gm

The above regex needs to match a word boundary after keyword @here and the underscore character _ is actually a word character. So, the regex won't match markdown input _@here_.

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

As we consider composer input as markdown and the underscore character _ is used by the Markdown bold syntax, I think we need to handle the special case of underscore character _ followed right after the @here syntax. We need to check if @here is

  1. followed by word boundary or
  2. underscore+word boundary.

So, we can also use below new regex

/[`.a-zA-Z]?@here(?=_\b|\b)(?![^<]*(<\/pre>|<\/code>|<\/a>))/gm

to replace the current one, which will not need to modify the replacement method. (?=_\b|\b) will check if @here is followed by word boundary or underscore+word boundary.

Below demo video

Screen.Recording.2023-06-04.at.8.48.02.AM.mov

uses the regex of combined solution from the proposal of the other issue(I think we can fix them separately but including it here just to demonstrate relevant unit test cases) to not parse here mention for input like [_@here_](google.com)

The regex of the combined solution is

/[`.a-zA-Z]?@here(?=_\b|\b)(?!((?:(?!<a).)+)?<\/a>|[^<]*(<\/pre>|<\/code>))/gm

Below code snippet will be helpful for testing

test('Test for @here mention example', () => {
    const testCases = [
        "@here",
        "_@here_",
        "`@here`",
        "```@here```",
        "[@here](google.com)",
        "[_@here_](google.com)",
        "[*@here*](google.com)",
        "[~@here~](google.com)",
        "@here_123",
        "@here_abc",
        "@here123",
        "@hereabc",
        "@here abc",
        "@here*",
        "@here~",
        "@here#",
        "@here`",
        "@here@",
        "@here$",
        "@here^",
        "@here(",
    ]

    console.log(testCases.map(t => `${t}\t=> ${parser.replace(t)}`).join('\n'));
});

Output will be like

@here     => <mention-here>@here</mention-here>
_@here_   => <em><mention-here>@here</mention-here></em>
`@here`   => <code>@here</code>
```@here```       => <pre>@here</pre>
[@here](google.com)       => <a href="https://google.com" target="_blank" rel="noreferrer noopener">@here</a>
[_@here_](google.com)     => <a href="https://google.com" target="_blank" rel="noreferrer noopener"><em>@here</em></a>
[*@here*](google.com)     => <a href="https://google.com" target="_blank" rel="noreferrer noopener"><strong>@here</strong></a>
[~@here~](google.com)     => <a href="https://google.com" target="_blank" rel="noreferrer noopener"><del>@here</del></a>
@here_123 => @here_123
@here_abc => @here_abc
@here123  => @here123
@hereabc  => @hereabc
@here abc => <mention-here>@here</mention-here> abc
@here*    => <mention-here>@here</mention-here>*
@here~    => <mention-here>@here</mention-here>~
@here#    => <mention-here>@here</mention-here>#
@here`    => <mention-here>@here</mention-here>&#x60;
@here@    => <mention-here>@here</mention-here>@
@here$    => <mention-here>@here</mention-here>$
@here^    => <mention-here>@here</mention-here>^
@here(    => <mention-here>@here</mention-here>(

What alternative solutions did you explore? (Optional)

N/A

@melvin-bot melvin-bot bot added the Overdue label Jun 2, 2023
@allroundexperts
Copy link
Contributor

Proposal

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

Italic _@here_ is not displayed as mention.

What is the root cause of that problem?

Now hereMention rule is applied before italic rule. Current regexp is as follows.

   regex: /[`.a-zA-Z]?@here\b(?![^<]*(<\/pre>|<\/code>|<\/a>))/gm,

We use \b in order to match @hero word, that is, @here needs to be followed by space character. But _ is considered as a word character and doesn't match. This is the root cause.

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

Including _ to the space character group would solve the issue successfully.

   regex: /[`.a-zA-Z]?@here(?=[\s_])(?![^<]*(<\/pre>|<\/code>|<\/a>))/gm,

image

Result

What alternative solutions did you explore? (Optional)

Thanks for your proposal @s-alves10, but your proposed regex doesn't seem to handle @here without anything after it.

@melvin-bot melvin-bot bot removed the Overdue label Jun 2, 2023
@allroundexperts
Copy link
Contributor

@eh2077 I'm confused about your proposal. Is there any case that your approach covers that this doesn't?

@eh2077
Copy link
Contributor

eh2077 commented Jun 3, 2023

@allroundexperts Thanks for checking proposals! Below is that regex test result comparing on test cases provided in my proposal FYI

@eh2077 's proposal @getusha 's proposal
image image

Based on the test above my proposal covers 3 more test cases

@here_123
@here_abc

@here123

@getusha Hope you don’t mind my testing above as I just did it as requested by the C+ team 🙏

@dummy-1111
Copy link
Contributor

Proposal

Updated

@allroundexperts
Thank you for your feedback

@hayata-suenaga
Copy link
Contributor

ah I didn't see the commnet

assigning @eh2077

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

melvin-bot bot commented Jun 6, 2023

📣 @eh2077 You have been assigned to this job by @hayata-suenaga!
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 📖

@eh2077
Copy link
Contributor

eh2077 commented Jun 6, 2023

@allroundexperts @hayata-suenaga The PR Expensify/expensify-common#544 for expensify-common is ready. Please help to review it at your convenience, thanks!

@conorpendergrast
Copy link
Contributor

Looks like the second PR is under review

@conorpendergrast
Copy link
Contributor

Hired @allroundexperts and @eh2077 via Upwork

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Jun 14, 2023
@melvin-bot melvin-bot bot changed the title [$1000] Chat - Italic _@here_ is not displayed as mention [HOLD for payment 2023-06-21] [$1000] Chat - Italic _@here_ is not displayed as mention Jun 14, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jun 14, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 14, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jun 14, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.27-7 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-06-21. 🎊

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 Jun 14, 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:

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

@allroundexperts
Copy link
Contributor

Here are the items from the checklist.

  1. Offending PR [No QA] Add rule to recognize user @here mentions expensify-common#532
  2. Commented on the PR https://github.com/Expensify/expensify-common/pull/532/files#r1233141987
  3. I don't think there needs to be a checklist change here since this involved good regex knowledge of the reviewer / contributor in order to be caught.
  4. I think that we should add this to our regression tests. Test steps in the issue description look good for the regression test.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jun 21, 2023
@bernhardoj
Copy link
Contributor

bernhardoj commented Jun 22, 2023

@conorpendergrast hi, will I get a reporting bonus here as I reported it earlier #19857 (comment)?

@conorpendergrast
Copy link
Contributor

@bernhardoj Yes, thank you for highlighting that

@conorpendergrast
Copy link
Contributor

Offer sent to @bernhardoj.

Paid and ended contract for @eh2077 and @allroundexperts

@conorpendergrast
Copy link
Contributor

Regression test issue created: https://github.com/Expensify/Expensify/issues/294092

@eh2077
Copy link
Contributor

eh2077 commented Jun 22, 2023

Hi @conorpendergrast , thanks for checking the payment! Can we apply for speed bonus for this issue as we got the two PRs merged within 3 working days(based on the local time)? Here's the timeline FYI

Assigned: Jun 6, 2023 at 9:30 PM GMT+8
Merged(The second PR): Jun 10, 2023 at 3:42 AM GMT+8

@conorpendergrast
Copy link
Contributor

I agree. From our internal process:

Note: If the contributor/c+ work was done within the speed bonuses but only merged later on due to internal engineering delays we can still pay out the speed bonus. As an example: if the PR is approved by c+ within the 3 days and internal engineer doesn't approve+merge until the 4th day then typically the speed bonus should still apply. If you're unsure ask in #bug-zero.

@conorpendergrast
Copy link
Contributor

@bernhardoj paid and contract ended
Bonus paid to @eh2077 and @allroundexperts.

Aaaand we're done! Thanks for playing, see you next time

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

9 participants