Skip to content

[dev] [Marfuen] mariano/fix-policy-digest-false-positives#2594

Merged
Marfuen merged 2 commits intomainfrom
mariano/fix-policy-digest-false-positives
Apr 18, 2026
Merged

[dev] [Marfuen] mariano/fix-policy-digest-false-positives#2594
Marfuen merged 2 commits intomainfrom
mariano/fix-policy-digest-false-positives

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 18, 2026

This is an automated pull request to merge mariano/fix-policy-digest-false-positives into dev.
It was created by the [Auto Pull Request] action.


Summary by cubic

Fixes false‑positive policy digest emails and rolls up pending policies into one email per user across orgs, while skipping inactive orgs and honoring per‑org unsubscribes.

  • Bug Fixes

    • Compare policy.signedBy to member.id (not member.user.id) to avoid false positives; adds regression tests including multi‑role members.
    • Guard array access in the @trycompai/email digest template and subject helper for noUncheckedIndexedAccess to fix DTS builds.
  • New Features

    • Roll up pending policies across orgs into a single email per user; per‑org unsubscribes remove only that org from the rollup.
    • Add computePolicyAcknowledgmentDigestSubject in @trycompai/email; update the digest template for multi‑org sections and per‑org buttons.
    • Filter inactive orgs at the DB query (hasAccess, onboardingCompleted, and a session in the last 90 days).
    • Task metrics: add recipients; rename emailsSkippedUnsubscribed to orgsSkippedUnsubscribed.

Written for commit c50eccf. Summary will update on new commits.

The helper compared policy.signedBy[] against member.user.id, but signedBy
stores member ids (written by the portal accept action and read by every
other consumer). Users who had signed their policies were still receiving
daily digest emails — the comparison never matched. Switched to member.id
with an inline regression test covering the reported owner+employee case.

Also roll up pending policies across orgs by user.id so a person with
memberships in multiple orgs receives one email with per-org sections
instead of one email per org. Per-org unsubscribe is still honored: a
user opted out of policy notifications in org A only drops that org from
the rollup and still gets an email about org B.

Finally, match weekly-task-reminder's dead-org filter at the DB query —
hasAccess, onboardingCompleted, and at least one non-deactivated member
with a session updated in the last 90 days — so we stop sending to
abandoned orgs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview, Comment Apr 18, 2026 4:29pm
comp-framework-editor Ready Ready Preview, Comment Apr 18, 2026 4:29pm
portal Ready Ready Preview, Comment Apr 18, 2026 4:29pm

Request Review

Copy link
Copy Markdown

@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 6 files

Requires human review: Significant logic changes to the notification task, including multi-org rollup logic and inactivity filtering, which impact core compliance communication.

DTS build failed because noUncheckedIndexedAccess types array[0] as
possibly undefined, even right after a length check. Destructure and
narrow with a truthy guard so strict TS accepts the template and the
shared subject helper.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@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.

0 issues found across 1 file (changes from recent commits).

Requires human review: This PR introduces significant changes to core business logic regarding policy notifications, including cross-org rollup and inactivity filtering, which requires human review.

@Marfuen Marfuen merged commit 7269f59 into main Apr 18, 2026
11 checks passed
@Marfuen Marfuen deleted the mariano/fix-policy-digest-false-positives branch April 18, 2026 16:29
@claudfuen
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.23.6 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants