Skip to content

Fix compliance case reopen check to exclude all terminal statuses - #410

Merged
Abidoyesimze merged 1 commit into
Neurowealth:mainfrom
sammajayi:fix/compliance-case-reopen-check-393
Aug 30, 2026
Merged

Fix compliance case reopen check to exclude all terminal statuses#410
Abidoyesimze merged 1 commit into
Neurowealth:mainfrom
sammajayi:fix/compliance-case-reopen-check-393

Conversation

@sammajayi

Copy link
Copy Markdown
Contributor

Summary

  • checkAndOpenCase (src/compliance/cases.ts) decided whether to attach a new high-risk-score event to an existing case using status: { not: 'CLOSED_NO_ACTION' } — flagged in the code as a // simplified condition.
  • The actual CaseStatus enum (prisma/schema.prisma) has two other terminal states this missed: SAR_FILED and CLEARED. A user with a case closed in either of those would have a new high-score event incorrectly attach evidence to the closed case instead of opening a fresh one.
  • Replaced the single-status check with an explicit TERMINAL_CASE_STATUSES list (SAR_FILED, CLEARED, CLOSED_NO_ACTION) and a notIn filter, using the real CaseStatus enum values from @prisma/client instead of a raw string literal (so a typo or a future enum rename fails to compile instead of silently misbehaving).
  • PENDING_SAR, OPEN, TRIAGE, INVESTIGATING, and ESCALATED remain non-terminal — a case in any of those still gets new evidence attached, unchanged from before.

Closes #393.

Test plan

  • New tests/unit/compliance/cases.test.ts (8 tests): below-threshold no-op, opens a new case when none exists, attaches evidence to an OPEN/INVESTIGATING case, and — the regression this issue is about — opens a fresh case for a user whose only case is closed as SAR_FILED or CLEARED (parametrized), plus an explicit check that the filter's notIn list contains every terminal status in the schema.
  • Full test suite (npm test) passes: 112 suites / 1530 tests.
  • tsc --noEmit and eslint clean.

…urowealth#393)

checkAndOpenCase's reopen lookup only excluded CLOSED_NO_ACTION
(`status: { not: 'CLOSED_NO_ACTION' }`). The CaseStatus enum
(prisma/schema.prisma) has two other terminal states — SAR_FILED and
CLEARED — that the filter didn't account for, so a new high-score event on
a user with one of those closed cases would incorrectly attach evidence to
it instead of opening a fresh case.

Replaces the single-status check with an explicit TERMINAL_CASE_STATUSES
list (SAR_FILED, CLEARED, CLOSED_NO_ACTION) and a `notIn` filter, using the
real CaseStatus enum values instead of a raw string literal.
@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@sammajayi Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Abidoyesimze
Abidoyesimze merged commit 7c2e4fa into Neurowealth:main Aug 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compliance case reopen check only excludes one closed status

2 participants