fix(billing): warn paying build-only orgs that exceed their plan
Problem
The admin "Above Plan Without Credits" count is rising. On 2026-11-24 prod had 14 active paying orgs above plan with no usable credits. 12 got the weekly user:upgrade_to_* email on 2026-11-23, and Bento's "Your Capgo plan needs attention" template shows opens and clicks from them. 2 orgs (EquiFarmX at 393%, UnPurchase at 270%) never got any warning.
Both orgs use only native builds and have never uploaded a bundle, so is_onboarded_org is false. handleOrgNotificationsAndEvents checked plan usage only for onboarded orgs, which meant:
userAbovePlannever ran, so no credit application, no exceeded flags and no upgrade emailis_good_plankept its raw or stale value. UnPurchase staystrueat 270%, so the console never shows the "Plan limit reached" banner.
Fix
Run the plan-usage branches when the org is onboarded or has an active plan entitlement. The onboarding email path for non-paying orgs stays the same.
Review follow-ups:
- A paying org that is still onboarding now gets both the onboarding email and its 50/70/90% usage alerts.
syncSubscriptionAndEventsreloads the org after the Stripe sync and uses the fresh plan calculation, the same onecron_stat_orguses. It also saves the credit-adjustedis_good_plan, guarded on product and price, socan_use_moreupdates right away. I removed the unused cachedcalculatePlanStatus.
Tests
- New unit test: a paying org that is not onboarded and is over plan gets
user:upgrade_to_maker,finalIsGoodPlan=falseand exceeded flags. The test fails without the fix. tests/plans.unit.test.ts: 11/11 pass. eslint is clean.
No UI change. The banner already handles can_use_more=false, and this fix makes that value correct for these orgs.
🤖 Generated with Claude Code

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.
Summary by CodeRabbit
- Bug Fixes
- Plan-usage checks and applicable overage or usage alerts now include organizations with an active plan, even if onboarding is incomplete.
- Eligible organizations can receive an onboarding reminder alongside a usage-threshold alert. Plan and trial checks now use refreshed subscription information, with credit-adjusted eligibility saved when subscription details match.
- Tests
- Added coverage for active-plan organizations with incomplete onboarding, including usage status and notification behavior.