← Back to PRs

#20190: WhatsApp: normalize BR 9th-digit outbound targets

by saurabhchopade open 2026-02-18 16:45 View on GitHub →
channel: whatsapp-web size: S
## Summary - add WhatsApp-specific Brazilian mobile normalization for outbound targets - when target matches `+55DD9XXXXXXXX` and DDD is outside `11-28`, strip the carrier-added `9` before send - keep DDD `11-28` unchanged - apply this normalization for both plain numbers and WhatsApp user JID inputs Closes #20187 ## Validation - `corepack pnpm exec vitest run src/whatsapp/normalize.test.ts` - `corepack pnpm exec vitest run src/whatsapp/resolve-outbound-target.test.ts` - `corepack pnpm dlx oxfmt@0.33.0 --check src/whatsapp/normalize.ts src/whatsapp/normalize.test.ts` <!-- greptile_comment --> <h3>Greptile Summary</h3> Adds WhatsApp-specific Brazilian mobile number normalization to strip the carrier-added 9th digit for outbound targets when the DDD (area code) falls outside the 11-28 range. Numbers with DDDs 11-28 (São Paulo, Rio de Janeiro, Espírito Santo regions) are kept unchanged, matching WhatsApp's internal number storage behavior. - New `normalizeBrazilianMobileForWhatsApp` function in `src/whatsapp/normalize.ts` that post-processes E.164 numbers - Applied consistently in both code paths of `normalizeWhatsAppTarget` (plain numbers and user JID inputs) - Tests cover DDD inside range (11), DDD outside range (47), and all three input formats (`+55...`, `whatsapp:+55...`, `...@s.whatsapp.net`) <h3>Confidence Score: 4/5</h3> - This PR is safe to merge - a well-scoped, targeted normalization change with matching tests. - Score of 4 reflects a clean, focused change with correct logic, consistent application across both code paths, and good test coverage. The DDD boundary (11-28) aligns with known WhatsApp behavior for Brazilian mobile numbers. No logic, syntax, or security issues found. - No files require special attention. <sub>Last reviewed commit: a1957da</sub> <!-- greptile_other_comments_section --> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) <!-- /greptile_comment -->

Most Similar PRs