#2772: fix: search WhatsApp account subdirs for LID mapping files
Cluster:
WhatsApp and Google Chat Fixes
## Summary
Fixes #2771
When `jidToE164()` is called without `opts.authDir` (e.g., from `extract.ts` in `describeReplyContext()`), the LID reverse mapping lookup fails because `resolveLidMappingDirs()` only searches the top-level credentials directory, not the `whatsapp/<accountId>/` subdirectories where the mapping files are actually stored.
This causes the reply-to-bot trigger in groups to fail when the bot's JID uses the WhatsApp LID format, as the implicit mention comparison can't resolve the LID to an E164 phone number.
## Changes
Updated `resolveLidMappingDirs()` in `src/utils.ts` to also search WhatsApp account subdirectories (`~/.clawdbot/credentials/whatsapp/*/`).
## Testing
1. Set up WhatsApp with a number using LID format
2. Join a group with `/activation mention`
3. Reply to bot's message without @mentioning
4. Bot now correctly responds (implicit mention via reply-to-bot)
Verified working on Clawdbot 2026.1.24-3.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
Investigated the change to `resolveLidMappingDirs()` in `src/utils.ts`, which extends LID reverse-mapping discovery to also search WhatsApp account subdirectories under the credentials directory (e.g. `credentials/whatsapp/*/`). This aligns the implicit `jidToE164()` lookup behavior with where mapping files are actually stored when `opts.authDir` isn’t provided (notably in reply-context flows).
No correctness issues were found in the change given the PR’s stated intent; it is a narrowly-scoped path discovery adjustment that should restore LID resolution in group reply-to-bot scenarios without affecting unrelated auth directory usage.
<h3>Confidence Score: 4/5</h3>
- This PR looks safe to merge; it’s a small, targeted directory-discovery change.
- Only a single utility function is adjusted to search additional subdirectories for mapping files; the change is limited in scope and consistent with reported bug behavior. Confidence isn’t 5 because this review did not execute runtime tests across different OS/path layouts and credential directory configurations.
- src/utils.ts (directory traversal logic)
<!-- greptile_other_comments_section -->
<sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#23059: fix(whatsapp): resolve LID JIDs for reply-to-bot implicit mention d...
by azisseno · 2026-02-21
89.3%
#23046: fix(whatsapp): detect LID JID in implicit reply-to-bot mention check
by hydro13 · 2026-02-21
86.7%
#11166: fix(whatsapp): detect LID @mentions in self-chat mode
by mcaxtr · 2026-02-07
86.3%
#16655: fix(whatsapp): resolve reply-to sender E.164 for LID JIDs (have bot...
by mascarenhas · 2026-02-15
85.1%
#17256: fix: allow text regex fallback when bot JID not in mentionedJids
by DarlingtonDeveloper · 2026-02-15
82.1%
#15786: fix: strip device suffix from selfJid in WhatsApp mention matching
by kenken64 · 2026-02-13
80.9%
#12069: fix(whatsapp): handle native group @mentions with requireMention
by abhishek0450 · 2026-02-08
80.5%
#5665: fix: match group JIDs in groupAllowFrom allowlist
by koala73 · 2026-01-31
79.1%
#23251: fix(whatsapp): include LID in implicit mention detection for group ...
by SidQin-cyber · 2026-02-22
78.8%
#6567: fix: include paired users in WhatsApp group sender allowlist
by giannisanni · 2026-02-01
78.6%