Skip to content

feat: show DueInvoiceBanner to all team/org members when invoiceUrl is mailto#28670

Draft
sean-brydon wants to merge 2 commits intomainfrom
devin/1774856424-mailto-due-invoice-banner
Draft

feat: show DueInvoiceBanner to all team/org members when invoiceUrl is mailto#28670
sean-brydon wants to merge 2 commits intomainfrom
devin/1774856424-mailto-due-invoice-banner

Conversation

@sean-brydon
Copy link
Copy Markdown
Member

What does this PR do?

When a team/org dunning record has a mailto: link as its invoiceUrl (i.e. not a Stripe payment URL), the DueInvoiceBanner is now shown to every member of that team/org — not just users with billing permission.

Previously: Only ADMIN/OWNER users with manageBilling permission saw the due invoice banner.

Now: The existing behavior is preserved for Stripe invoice URLs. Additionally, for mailto: invoice URLs, all accepted team/org members will also see the banner so they are aware of the outstanding invoice.

Implementation

In DueInvoiceService.getBannerDataForUser:

  1. Fetches billing-permitted teams (existing behavior, unchanged)
  2. New: Also fetches all teams the user is a member of
  3. For teams where the user does NOT have billing permission, queries for overdue prorations where invoiceUrl starts with mailto:
  4. Merges and deduplicates results

Also migrated the proration queries from include to select per project conventions.

Important Review Points

  • The findAllMemberTeamIds helper intentionally queries ALL memberships (no role filter) — this is needed so regular MEMBER-role users see the mailto banners
  • The early return if (teamsWithBillingPermission.length === 0) return [] was removed so users with no billing permission can still see mailto-based banners
  • The invoiceUrl: { startsWith: "mailto:" } Prisma filter is the gating mechanism that limits which prorations non-billing members can see

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Create a team/org with a MonthlyProration record that has status: "INVOICE_CREATED" and invoiceUrl set to a mailto: link (e.g. mailto:billing@org.com)
  2. Log in as a regular MEMBER of that team (not ADMIN/OWNER)
  3. Verify the due invoice banner appears at the top of the page
  4. Verify the "Pay now" link opens the mailto URL
  5. Verify that for teams with a regular Stripe invoiceUrl, non-billing members still do NOT see the banner (existing behavior preserved)

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

Link to Devin session: https://app.devin.ai/sessions/b745fa9d22fc439ab38bade8514d4af8
Requested by: @sean-brydon

devin-ai-integration bot and others added 2 commits March 30, 2026 07:42
…s a mailto link

Co-Authored-By: sean@cal.com <Sean@brydon.io>
Co-Authored-By: sean@cal.com <Sean@brydon.io>
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant