#15786: fix: strip device suffix from selfJid in WhatsApp mention matching
channel: whatsapp-web
stale
size: XS
Cluster:
WhatsApp and Google Chat Fixes
## Problem
When WhatsApp runs as a linked device, the `selfJid` has a device suffix (e.g., `6580835862:2@s.whatsapp.net`). The regex intended to strip this suffix used `/:\\d+/` (escaped backslash + literal 'd') instead of `/:\d+/` (colon + digits), so the suffix was never removed.
This caused `wasMentioned` to always be `false` in group chats because the `normalizedMentionedJids` (E.164 format like `+6580835862`) could never match the unstripped `selfJid`.
## Fix
Changed the regex from `/:\\d+/` to `/:\d+/` in three places:
- `src/web/auto-reply/mentions.ts` — `resolveMentionTargets`
- `src/web/auto-reply/monitor/group-gating.ts` — `applyGroupGating` (selfJid + replySenderJid)
Fixes #15783
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR fixes WhatsApp mention matching on linked devices by correcting the regex used to strip the `:<device>` suffix from JIDs. Specifically, it updates `/:\\d+/` (which matches a literal `\d`) to `/:\d+/` in `resolveMentionTargets` and in group gating’s implicit-mention comparison, so `selfJid` / `replyToSenderJid` normalize from e.g. `6580…:2@s.whatsapp.net` to `6580…@s.whatsapp.net` and can match expected mention targets.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- Changes are small, localized, and correct a plainly broken regex that previously could not match WhatsApp linked-device JID suffixes. The updated regex aligns with existing JID parsing elsewhere in the repo and does not alter control flow beyond intended normalization.
- No files require special attention
<sub>Last reviewed commit: b80085d</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#12069: fix(whatsapp): handle native group @mentions with requireMention
by abhishek0450 · 2026-02-08
83.0%
#23046: fix(whatsapp): detect LID JID in implicit reply-to-bot mention check
by hydro13 · 2026-02-21
82.9%
#22106: fix(whatsapp): honor selfChatMode override for group mentions
by sportclaw · 2026-02-20
82.7%
#10196: fix(whatsapp): sanitize raw mention IDs in outbound messages
by koala73 · 2026-02-06
82.1%
#17256: fix: allow text regex fallback when bot JID not in mentionedJids
by DarlingtonDeveloper · 2026-02-15
81.9%
#11166: fix(whatsapp): detect LID @mentions in self-chat mode
by mcaxtr · 2026-02-07
81.3%
#2772: fix: search WhatsApp account subdirs for LID mapping files
by impozzible · 2026-01-27
80.9%
#7395: fix(whatsapp): strip markdown bold/italic from URLs before sending
by lailoo · 2026-02-02
80.3%
#8052: fix(whatsapp): strip leading whitespace from outbound messages
by FelixFoster · 2026-02-03
79.4%
#23059: fix(whatsapp): resolve LID JIDs for reply-to-bot implicit mention d...
by azisseno · 2026-02-21
79.3%