# Version 2.3.6 Lead Visibility + Owner Notification Fix

This patch fixes a case where the customer SMS flow worked, but the dashboard/owner alerts did not behave as expected.

## Problems addressed

1. TextBee and Telnyx may format the same phone number differently:
   - +13135551234
   - 13135551234
   - 3135551234

   The app now matches these as the same US number.

2. The AI could say "someone will call back" while `qualified` was still false.
   Owner email/SMS were waiting for the AI final reply gate, but the app did not always mark the conversation complete.

3. Owner notifications could be skipped because final handoff phrases did not include common wording like:
   - someone will call
   - someone would call
   - call you back
   - will reach out
   - office will call

## What changed

- Inbound SMS logs the lead it linked to:
  [Inbound SMS linked to lead]

- AI final handoff detection now recognizes more final reply phrases.

- If the AI sends a final handoff reply and the lead has:
  - customer name
  - service address
  - issue/service type

  the app marks:
  - conversation_complete = 1
  - qualified = 1
  - status = qualified
  - lead_score at least 80
  - archived = 0

- Owner alert logs now show whether the required lead details were present.

- Added debug endpoint:
  GET /admin/api/leads-debug/recent

## Logs to check

- [Inbound SMS linked to lead]
- [AI reply not treated as final owner handoff yet]
- [Conversation marked complete after AI final reply]
- [Owner alert check]
- [Owner alert sending]
- [Owner alert completed]
