Fix parsing short mentions when sending message to backend#65237
Conversation
dab6846 to
207746e
Compare
207746e to
a19fff4
Compare
|
@shubham1206agra Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
| **Short mention** - is a mention containing only the login part of users email. This basically means that any phrase starting with `@` _could be considered_ a short mention. We only highlight `@mention` if it matches a login from user's personalDetails and has the same email domain. | ||
| When parsed via ExpensiMark into html, it is described with tag `<mention-short>`. | ||
| Examples of short mentions: | ||
| - `@vit` - would only get highlighted IF my domain is `expensify.com` and there exists a user with email `john.doe@expensify.com` |
There was a problem hiding this comment.
May be clearer in such way:
Scenario 1:
My email: XD@expensify.com
Mentionee email: vit@expensify.com
Highlighted mention: @vit
Scenario 2:
My email: XD@expensify.com
Mentionee email: vit@test.com, there is no user vit@expensify.com
NOT Highlighted mention: @vit
There was a problem hiding this comment.
Since it's hard in markdown to do nicely formatted lists - xxx with multiple lines per point I didn't include this verbatim, but edited my phrasing to be more clear
2ec75c2 to
4f95d5a
Compare
|
@shubham1206agra ready for your review |
| extras: parserOptions.extras, | ||
| }); | ||
|
|
||
| const textWithHandledMentions = parsedText.replace(CONST.REGEX.SHORT_MENTION_HTML, (fullMatch, group1) => { |
There was a problem hiding this comment.
@Kicu We need to make sure this does not get trigger inside code block. Can you please check for that?
There was a problem hiding this comment.
@shubham1206agra this line runs after Parser.replace. This means the new regex runs on the code that ExpensiMark had already parsed.
So it's ExpensiMark parser that guarantees that <mention-short (or any other mention) will not appear inside code block. I have verified with @Skalakid that this can not happen.
However even if it would ever happen - then we'd fix it inside ExpensiMark. The code that runs in this line does not require any extra checks.
|
@shubham1206agra responded and fixed the Readme comment. |
| * Currently because of the way we parse short mentions we shouldn't ever NOT escape text - it will affect what mentions get parsed | ||
| * This should be removed after https://github.com/Expensify/App/issues/50724 as a followup | ||
| */ | ||
| shouldEscapeText?: boolean; |
There was a problem hiding this comment.
@Kicu This might be problematic since we want to escape html tags directly present in message before parsing.
There was a problem hiding this comment.
Test this message as input
`<mention-short>@lol</mention-short>`
It's get rendered as @lol instead of <mention-short>@lol</mention-short>
There was a problem hiding this comment.
Sorry I'm not sure I understand.
How would this <mention-short>@lol</mention-short> appear in the input and why do we want to support the tags?
Like what you described sounds exactly correct - a user should never see the tag <mention-short> exactly the same like user will never see <mention-here>@here</mention-here> just @here.
Also later down the line we unescape the text.
I need more description from you or a more specific scenario that breaks.
There was a problem hiding this comment.
discussed on slack and solved
bfb9733 to
33f879b
Compare
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeScreen.Recording.2025-07-14.at.6.29.37.PM.moviOS: HybridAppScreen.Recording.2025-07-14.at.6.54.38.PM.moviOS: mWeb SafariScreen.Recording.2025-07-14.at.6.25.00.PM.movMacOS: Chrome / SafariScreen.Recording.2025-07-14.at.6.12.38.PM.movMacOS: DesktopScreen.Recording.2025-07-14.at.6.39.34.PM.mov |
|
@puneetlath please remember to review this 🙏 this is 2weeks old, I'd like to merge soon if no bugs are found |
|
Good job with this! Let's keep our eye out for deploy blockers. |
|
🚀 Deployed to staging by https://github.com/puneetlath in version: 9.1.82-1 🚀
|
|
🚀 Deployed to production by https://github.com/luacmartins in version: 9.1.82-7 🚀
|
This PR fixes a bug related to mentions, but also slightly changes the flow of parsing mentions before sending them to backend.
Explanation of Change
's#50724 (comment)Parser.replacecall like we used to do, because then we have 2 different ways of parsing short mentionsParser.replaceis called insidegetParsedMessageWithShortMentionswhich will then traverse the resulting HTML and replace all short mentions with full mentionsNote: there are problems with running android related to new SignInPage so I couldn't record android video. (this needs to be merged: #65178)
Fixed Issues
$ #50724
PROPOSAL:
Tests
's#50724Offline tests
QA Steps
See Tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
rec-mentions-ios.mp4
iOS: mWeb Safari
MacOS: Chrome / Safari
rec-mentions-web.mp4
MacOS: Desktop