#17256: fix: allow text regex fallback when bot JID not in mentionedJids
channel: whatsapp-web
stale
size: XS
Cluster:
WhatsApp and Google Chat Fixes
## Summary
- Remove the early `return false` in `isBotMentionedFromTargets()` that short-circuited text regex matching when `mentionedJids` contained other users' JIDs
- Fix: bot now correctly responds when addressed by name even when someone else is @mentioned in the same message
- Fix: WhatsApp LID mismatches no longer silently suppress mention detection — the function falls through to regex matching instead of returning false
**Bug:** When a WhatsApp group message contained *any* `mentionedJids` and the bot's JID wasn't in the list, the function returned `false` immediately without attempting text-based regex matching. This meant the bot ignored messages where it was addressed by name alongside an @mention of another user, or where WhatsApp's LID→JID resolution failed.
## Test plan
- [x] Updated existing test: "ignores regex matches when other mentions are present" → now expects `true` (renamed to "falls through to regex when bot JID not in mentionedJids")
- [x] Added new test: "returns false when neither JID nor regex match with other mentions present"
- [x] All existing tests pass (JID match, self-chat, no-mention regex fallback, LID mapping)
- [x] Full test suite: 861 passed, 11 failed (all pre-existing — missing optional extension deps)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Removes early return that prevented text-based mention detection when `mentionedJids` contained other users. The bot now correctly responds when addressed by name even if someone else is `@mentioned`, and gracefully handles WhatsApp LID→JID resolution failures by falling through to regex matching instead of silently returning false.
<h3>Confidence Score: 5/5</h3>
- Safe to merge - simple logic fix with comprehensive test coverage
- The change removes a premature return statement that blocked regex matching fallback, which is exactly what the bug required. The fix is minimal (removes 2 lines, adds 4 comment lines), preserves all existing behavior paths (JID matching, self-chat handling), and adds appropriate test coverage for both the fixed case and the negative case. All existing tests pass according to the PR description.
- No files require special attention
<sub>Last reviewed commit: 91733b0</sub>
<!-- greptile_other_comments_section -->
<sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#11166: fix(whatsapp): detect LID @mentions in self-chat mode
by mcaxtr · 2026-02-07
85.6%
#12069: fix(whatsapp): handle native group @mentions with requireMention
by abhishek0450 · 2026-02-08
83.6%
#2772: fix: search WhatsApp account subdirs for LID mapping files
by impozzible · 2026-01-27
82.1%
#15786: fix: strip device suffix from selfJid in WhatsApp mention matching
by kenken64 · 2026-02-13
81.9%
#23046: fix(whatsapp): detect LID JID in implicit reply-to-bot mention check
by hydro13 · 2026-02-21
81.7%
#22106: fix(whatsapp): honor selfChatMode override for group mentions
by sportclaw · 2026-02-20
80.7%
#16655: fix(whatsapp): resolve reply-to sender E.164 for LID JIDs (have bot...
by mascarenhas · 2026-02-15
79.5%
#23059: fix(whatsapp): resolve LID JIDs for reply-to-bot implicit mention d...
by azisseno · 2026-02-21
79.5%
#11774: fix: add guards for undefined mentionRegexes arrays
by ikvyk · 2026-02-08
79.5%
#8224: feat(whatsapp): extract @mentions into dedicated module
by zurizuriaria · 2026-02-03
78.5%