#12069: fix(whatsapp): handle native group @mentions with requireMention
channel: whatsapp-web
Cluster:
WhatsApp and Google Chat Fixes
## Issue
Fixes #11758
WhatsApp native `@mention` detection fails in group chats when
`requireMention: true` is enabled and the owner number is included
in `allowFrom` (owner/self messages).
## Root Cause
When `requireMention` is enabled, native WhatsApp mentions using LID
identifiers (e.g. `181891881787642@lid`) were not correctly recognized,
causing valid group mentions to be ignored.
Two issues contributed to this:
1. Owner JID comparison was performed between incompatible formats
(bare JID vs E164), which could never match.
2. WhatsApp automatically includes the owner’s JID in `mentionedJids`
even when no explicit `@mention` is made, leading to false positives.
## Fix
- Removed the incorrect JID format comparison
- Added explicit owner/self-sender detection:
- If the sender **is the owner**, suppress auto-included JID mentions
- If the sender **is not the owner**, validate native `@mention`s
- Ensured explicit `false` return to prevent fallback to text-based
mention detection when JID mentions are present
## Tests
- Added unit tests in `mentions.test.ts` covering owner/self message cases
- Updated integration expectations in
`supports-always-group-activation-silent-token-preserves.test.ts`
- All mention unit tests pass
- All group mention integration tests pass
- Full web provider test suite passes (157/157)
- Linting and formatting checks pass
## 🤖 AI / Vibe-coded PR disclosure
- [x] **AI-assisted:** Yes — used AI tools for debugging, reasoning about edge
cases, and reviewing the solution. All code was written, verified, and
understood by me.
- [x] **Testing level:** Fully tested.
- Unit tests added/updated
- Integration tests updated
- Full web provider test suite passes (157/157)
- [x] **Prompts / session logs:** No production session logs included.
Debugging and reasoning were based on local reproduction and tests.
- [x] **Author understanding:** I understand what the code does and why these
changes are required, and I’m confident the fix preserves existing behavior.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR adjusts WhatsApp group @mention detection when `requireMention: true` is enabled in “self-chat mode” (where `allowFrom` contains the owner/self number). The mention logic in `src/web/auto-reply/mentions.ts` now:
- Treats any presence of `mentionedJids` as authoritative (no regex fallback) for non-self-chat mode.
- In self-chat mode, ignores auto-included self mentions only when the sender is the owner, while still honoring explicit JID/LID mentions from other senders.
Tests were updated/added to cover self/owner message suppression, non-owner native mentions, and adjusted integration expectations for group activation behavior.
<h3>Confidence Score: 4/5</h3>
- Mostly safe to merge, but there is a self-chat false-positive edge case if senderE164 is missing.
- The core logic change is small and tests cover the intended scenarios, but the new owner/self detection depends on `msg.senderE164` being present. If it’s absent on some inbound messages, owner messages with auto-included self JIDs can incorrectly trigger the bot in self-chat mode.
- src/web/auto-reply/mentions.ts
<!-- 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
#11166: fix(whatsapp): detect LID @mentions in self-chat mode
by mcaxtr · 2026-02-07
90.1%
#22106: fix(whatsapp): honor selfChatMode override for group mentions
by sportclaw · 2026-02-20
88.2%
#23046: fix(whatsapp): detect LID JID in implicit reply-to-bot mention check
by hydro13 · 2026-02-21
83.6%
#17256: fix: allow text regex fallback when bot JID not in mentionedJids
by DarlingtonDeveloper · 2026-02-15
83.6%
#15786: fix: strip device suffix from selfJid in WhatsApp mention matching
by kenken64 · 2026-02-13
83.0%
#4390: fix(whatsapp): allow media from allowlisted groups without groupAllow…
by Sarang19114 · 2026-01-30
82.5%
#23059: fix(whatsapp): resolve LID JIDs for reply-to-bot implicit mention d...
by azisseno · 2026-02-21
81.4%
#16655: fix(whatsapp): resolve reply-to sender E.164 for LID JIDs (have bot...
by mascarenhas · 2026-02-15
80.7%
#2772: fix: search WhatsApp account subdirs for LID mapping files
by impozzible · 2026-01-27
80.5%
#8224: feat(whatsapp): extract @mentions into dedicated module
by zurizuriaria · 2026-02-03
80.3%