Skip to content

[$175] Chat - short mention with a single character followed by dot isn't recognized #104159

Closed

Description

@nlemma

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.5.10-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://github.com/Expensify/Expensify/issues/557782
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Windows Windows 11 - Chrome

Action Performed:

  1. Open the WS chat
  2. Send a short mention with a single character followed by dot (for example, @j.doe)

Expected Result:

the mention is recognized

Actual Result:

the short mention isn't recognized

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Bug7265409_1789999915428.1789635851867_bandicam_2026-09-17_16-03-55-318.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit

Activity

  1. added
    Daily
    Bug
    on Oct 15, 2026
  2. MelvinBot commented on Oct 15, 2026

    @MelvinBot
    Contributor

    ⚠️ Preliminary analysis (low confidence): treat this as a starting point, not a conclusion.

    I don't think this is a code bug in the current build. The same bug was already fixed in expensify-common, and version 9.5.10 ships with that fix. More likely, the test accounts don't meet the conditions for short mentions.

    Why the parser isn't the likely cause

    What a short mention needs to resolve
    A short mention only resolves if all of these are true (src/hooks/useShortMentionsList.ts:27-43):

    1. The sender's login is on a private domain. Public domains such as gmail.com return an empty list.
    2. The mentioned user's login is on the same domain as the sender's.
    3. The mentioned user is in the sender's personal details.

    If the check passes, the composer keeps the highlight (src/libs/ParsingUtils.ts:23-43). Sending then expands it to a full mention (src/libs/ParsingUtils.ts:72-127). I found no rule in this path that limits length or dot placement.

    What I couldn't verify

    • I couldn't run ExpensiMark in this environment. The parser result above comes from reading the regex and the upstream test, not from running it.
    • I didn't try to reproduce it in the app. That needs two accounts on the same private domain, and the available test account uses a public domain.

    To confirm, please share:

    • The sender's login and the mentioned user's login, or at least their domains. Do they share the same private domain?
    • Whether the failure is in the composer highlight, in the sent message, or both.
    • Whether a longer short mention, such as @john.doe, works with the same two accounts.

    If a same-domain pair still fails, that points to a new cause, and this needs a deeper look.


    Next Steps: Reply with @MelvinBot <your feedback> to refine this analysis.


    view run

  3. added
    External
    on Oct 15, 2026
  4. melvin-bot commented on Oct 15, 2026

    @melvin-bot

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

  5. changed the title [-]Chat - short mention with a single character followed by dot isn't recognized[/-] [+][$175] Chat - short mention with a single character followed by dot isn't recognized[/+] on Oct 15, 2026
  6. melvin-bot commented on Oct 15, 2026

    @melvin-bot
  7. janiya2 commented on Oct 15, 2026

    @janiya2

    Contributor details
    Your Expensify account email: janithad2@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/janithad

    Proposal

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

    In chat, typing a short mention that starts with a single character followed by a dot (e.g. @j.doe) does not highlight or convert into a recognized mention badge when sent.


    What is the root cause of that problem?

    There are two layers involved in short mention handling in Expensify (as documented in contributingGuides/MENTIONS_HIGHLIGHTING_IN_CHAT.md):

    1. Tokenization Layer (ExpensiMark / expensify-common & @expensify/react-native-live-markdown):

      • The tokenization regex for shortMentions in ExpensiMark.ts:
        new RegExp(
            `${Constants.CONST.REG_EXP.PRE_MENTION_TEXT_PART}(@(?=((?=[\\w]+[\\w'#%+-]*(?:\\.[\\w'#%+-]+)*)[\\w\\.'#%+-]{1,64}(?= |_|\\b))(?!([:\\/\\\\]))(?<end>.*))(?!here)\\S{1,254}(?=\\k<end>$))(?!((?:(?!<a).)+)?<\\/a>|[^<]*(<\\/pre>|<\\/code>|<\\/mention-user>|<\\/mention-here>))`,
            'gim'
        )
      • Running the current shipped expensify-common@2.0.211 on @j.doe produces:
        <mention-short>@j.doe</mention-short>
      • Both upstream PRs (Expensify/expensify-common#881 and Expensify/expensify-common#891) are already present. The parser itself tokenizes single-char-dot mentions like @j.doe without issues.
    2. Resolution & Styling Layer (useShortMentionsList.ts & ParsingUtils.ts):

      • In accordance with Expensify's architecture guidelines:

        "Short mention - a special type of mention that contains only the login part of a user email AND the email domain has to be the same as our email domain. Any other @mention will not get highlighted if domains don't match."

      • Specifically, in useShortMentionsList.ts:
        const currentUserDomain = getEmailDomain(currentUserLogin);
        if (isDomainPublic(currentUserDomain)) {
            return emptyLoginsList;
        }
        
        const availableLogins: string[] = [];
        for (const personalDetail of Object.values(personalDetails)) {
            if (!personalDetail?.login || getEmailDomain(personalDetail.login) !== currentUserDomain) {
                continue;
            }
            const [username] = personalDetail.login.split('@');
            if (username) {
                availableLogins.push(username);
            }
        }
      • And in ParsingUtils.ts (decorateRangesWithShortMentions & addDomainToShortMention):
        if (availableMentions.includes(mentionValue)) {
            return { ...range, type: 'mention-user' };
        }
        and
        const mentionWithEmailDomain = `${mention}@${userPrivateDomain}`;
        if (availableMentionLogins.includes(mentionWithEmailDomain)) {
            return mentionWithEmailDomain;
        }

    Why it failed in the reporter's video:

    • In the attached video, the workspace is Applause's Workspace 16!.
    • The only member invited in the chat history is zc (fdbvdbxzn@gmail.com).
    • There is no member j.doe or j.doe@applause.expensifail.com in personal details or workspace members.
    • Because j.doe is not an existing user on the sender's private domain, the app intentionally does not format @j.doe into a mention badge (preventing arbitrary @strings from becoming broken mention links).
    • This is the exact identical situation seen in Issue #96348 (which had the identical regression test case ID https://github.com/Expensify/Expensify/issues/557782), where the issue was confirmed not reproducible / invalid test prerequisites and closed.

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

    Primary Recommendation (QA / Test Verification):

    Verify with proper test prerequisites:

    1. Ensure the logged-in user is on a private domain (e.g. user1@testdomain.com).
    2. Invite a member whose login has a single character followed by a dot on the same private domain (e.g. j.doe@testdomain.com).
    3. Type @j.doe in the workspace chat.
    4. Result: The mention @j.doe is highlighted in the composer via decorateRangesWithShortMentions and sends as <mention-user>@j.doe@testdomain.com</mention-user> as expected.

    Alternative (If Product Team wants short mentions to resolve across all workspace members regardless of domain matching):

    If product design decides that short mentions within workspace chats should resolve for any workspace member even across different or public domains, we should update useShortMentionsList.ts and ReportUtils.ts to look up member logins from report.participants or policy.employeeList instead of strictly enforcing currentUserDomain === memberDomain:

    In src/hooks/useShortMentionsList.ts:

    --- a/src/hooks/useShortMentionsList.ts
    +++ b/src/hooks/useShortMentionsList.ts
    @@ -28,9 +28,6 @@ const buildAvailableLoginsList = memoize(
             if (!personalDetails) {
                 return emptyLoginsList;
             }
     
             const currentUserDomain = getEmailDomain(currentUserLogin);
    -        if (isDomainPublic(currentUserDomain)) {
    -            return emptyLoginsList;
    -        }
     
             const availableLogins: string[] = [];
             for (const personalDetail of Object.values(personalDetails)) {
    -            if (!personalDetail?.login || getEmailDomain(personalDetail.login) !== currentUserDomain) {
    +            if (!personalDetail?.login) {
                     continue;
                 }
     
                 const [username] = personalDetail.login.split('@');
                 if (username) {
                     availableLogins.push(username);
                 }
             }
             return availableLogins;

    What alternative solutions did you explore? (Optional)

    Investigated whether autocomplete suggestion handling in SuggestionMention.tsx had an issue with dotted handles; confirmed that PR #81262 already added normalizedPrefix handling for trailing dots, so typing @j. or @j.doe matches any existing member whose handle starts with j. without issues.

  8. melvin-bot commented on Oct 15, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  9. stacklancer commented on Oct 18, 2026

    @stacklancer

    @ahmedGaber93 I tested this with two accounts on the same private domain (r.bhati@stacklance.in and rahul@stacklance.in) on web, on latest main.

    From rahul@ I typed @r.bhati test in the DM:

    • the composer highlights @r.bhati as a mention
    • after sending, the message shows a proper mention for @r.bhati@stacklance.in

    So a short mention with a single character followed by a dot works when both users share a private domain. My guess is the tester used accounts on a public domain (like gmail.com) or on different domains, where short mentions are not supported by design (useShortMentionsList returns an empty list for public domains). That matches what MelvinBot suggested above.

    It may be worth asking the tester which two logins they used before going further.

    Image
  10. jloa-dev commented on Oct 19, 2026

    @jloa-dev

    Contributor details
    Your Expensify account email: jloa.dev@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~01584ea0bc208b0a94

    Proposal

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

    In chat, short user mentions where the username starts with a single character followed by a dot (e.g. @j.doe) are not recognized as valid mentions.

    What is the root cause of that problem?

    In src/libs/MentionUtils.ts (and CONST.REGEX.MENTION / CONST.REGEX.USER_MENTION), the regex pattern governing user mentions requires at least two alphanumeric characters before a dot separator or boundary (e.g. [a-zA-Z0-9_-]{2,}). When a handle uses a standard initials-based format like j.doe, the single-character prefix fails the length quantifier and is treated as plain text rather than a mention token.

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

    1. In src/CONST.ts and src/libs/MentionUtils.ts, update CONST.REGEX.MENTION to permit single-character prefixes preceding a period (e.g., (?<=^|\s)@([a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+)*)).
    2. Ensure unit tests in tests/unit/MentionUtilsTest.ts cover single-character dotted usernames like @j.doe and @a.b.

    What alternative solutions did you explore? (Optional)

    Restricting mentions to full email addresses, which degrades UX for short usernames and workspace handles.

    Tests

    1. Open any chat room in New Expensify.
    2. In the compose box, type @j.doe and press send.
    3. Verify the mention is recognized, styled as a mention pill/link, and autocompletes correctly.
    4. Verify mentions like @john.doe and @user continue to work properly.
  11. melvin-bot commented on Oct 19, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  12. bonnhatnguyen commented on Oct 19, 2026

    @bonnhatnguyen

    Proposal

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

    In a workspace chat, sending a short mention starting with a single character followed by a dot (e.g. @j.doe) does not convert into an active mention badge or trigger mention styling.


    What is the root cause of that problem?

    1. Analysis of the Tokenizer / Parser:

    The mention regex for short mentions in ExpensiMark.ts / expensify-common@2.0.211 already supports single-character prefixes followed by a dot (following PRs expensify-common#881 and expensify-common#891).
    Running the parser on @j.doe:

    <mention-short>@j.doe</mention-short>

    The tokenization itself works properly and is covered by upstream unit tests (ExpensiMark-HTML-test.js:1791-1799).

    2. Root Cause in Resolution Layer (useShortMentionsList.ts & ParsingUtils.ts):

    As documented in contributingGuides/MENTIONS_HIGHLIGHTING_IN_CHAT.md:

    "Short mention - a special type of mention that contains only the login part of a user email AND the email domain has to be the same as our email domain. Any other @mention will not get highlighted if domains don't match."

    In src/hooks/useShortMentionsList.ts (lines 28–43):

    const currentUserDomain = getEmailDomain(currentUserLogin);
    if (isDomainPublic(currentUserDomain)) {
        return emptyLoginsList;
    }
    
    const availableLogins: string[] = [];
    for (const personalDetail of Object.values(personalDetails)) {
        if (!personalDetail?.login || getEmailDomain(personalDetail.login) !== currentUserDomain) {
            continue;
        }
        const [username] = personalDetail.login.split('@');
        if (username) {
            availableLogins.push(username);
        }
    }
    return availableLogins;

    And in src/libs/ParsingUtils.ts (decorateRangesWithShortMentions & addDomainToShortMention), a <mention-short> token only resolves and converts to <mention-user> if username exists in availableLogins.

    Why it did not highlight in the reporter's video:

    • In the attached video, the workspace is Applause's Workspace 16!.
    • The sender is an external tester account (@applause.expensifail.com).
    • There is no member named j.doe or j.doe@applause.expensifail.com in the workspace members or personal details list.
    • Because j.doe is not an existing user sharing the sender's private domain, the app intentionally leaves @j.doe as plain text to prevent arbitrary strings prefixed with @ from turning into broken mention links.
    • This is identical to Issue #96348 (which tested the exact same test case ID https://github.com/Expensify/Expensify/issues/557782), where the issue was investigated and closed as invalid test prerequisites / not a bug.

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

    Option A: Close as Expected Behavior & Update Testrail Prerequisites (Recommended)

    Verify with proper test prerequisites:

    1. Ensure the sender is logged into an account on a private domain (e.g. admin@mycompany.com).
    2. Add a member whose handle begins with a single char followed by a dot on the same private domain (e.g. j.doe@mycompany.com).
    3. Type @j.doe in the workspace chat.
    4. The mention highlights in the composer and sends as <mention-user>@j.doe@mycompany.com</mention-user> as expected.
      Update the regression test steps to specify that the target member must exist on the same private domain.

    Option B: Allow Short Mentions to Resolve for Any Workspace Member (If Product Change is Desired)

    If product desires short mentions to resolve across any workspace member regardless of whether their email domain matches the sender's domain:

    In src/hooks/useShortMentionsList.ts:

    --- a/src/hooks/useShortMentionsList.ts
    +++ b/src/hooks/useShortMentionsList.ts
    @@ -28,9 +28,6 @@ const buildAvailableLoginsList = memoize(
             if (!personalDetails) {
                 return emptyLoginsList;
             }
     
             const currentUserDomain = getEmailDomain(currentUserLogin);
    -        if (isDomainPublic(currentUserDomain)) {
    -            return emptyLoginsList;
    -        }
     
             const availableLogins: string[] = [];
             for (const personalDetail of Object.values(personalDetails)) {
    -            if (!personalDetail?.login || getEmailDomain(personalDetail.login) !== currentUserDomain) {
    +            if (!personalDetail?.login) {
                     continue;
                 }
     
                 const [username] = personalDetail.login.split('@');
                 if (username) {
                     availableLogins.push(username);
                 }
             }
             return availableLogins;

    What alternative solutions did you explore? (Optional)

    • Checked autocomplete suggestion filtering in SuggestionMention.tsx: Confirmed that PR #81262 already normalizes trailing dots, so typing @j. or @j.doe suggests matching users properly when they exist in member lists.

    Contributor details
    Your Expensify account email: bonnhatnguyen0@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~0139ed4098bdc50182

  13. melvin-bot commented on Oct 19, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  14. melvin-bot commented on Oct 20, 2026

    @melvin-bot

    @ahmedGaber93 Huh... This is 4 days overdue. Who can take care of this?

  15. melvin-bot commented on Oct 22, 2026

    @melvin-bot

    @ahmedGaber93 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

  16. melvin-bot commented on Oct 26, 2026

    @melvin-bot

    @ahmedGaber93 10 days overdue. I'm getting more depressed than Marvin.

  17. ahmedGaber93 commented on Oct 27, 2026

    @ahmedGaber93
    Contributor

    I Agree with Melvin #104159 (comment), this is not an issue, you must have j.doe in your personal detials to be able to mention him. e.g. invite them to a workspace first

    What a short mention needs to resolve

    1. The sender's login is on a private domain.
    2. The mentioned user's login is on the same domain as the sender's.
    3. The mentioned user is in the sender's personal details.
    Screen.Recording.2026-10-27.at.9.45.51.AM.mov
  18. ahmedGaber93 commented on Oct 27, 2026

    @ahmedGaber93
    Contributor

    Closed, this is not an issue #104159 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions