Fix compliance case reopen check to exclude all terminal statuses - #410
Merged
Abidoyesimze merged 1 commit intoAug 30, 2026
Merged
Conversation
…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.
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
checkAndOpenCase(src/compliance/cases.ts) decided whether to attach a new high-risk-score event to an existing case usingstatus: { not: 'CLOSED_NO_ACTION' }— flagged in the code as a// simplified condition.CaseStatusenum (prisma/schema.prisma) has two other terminal states this missed:SAR_FILEDandCLEARED. 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.TERMINAL_CASE_STATUSESlist (SAR_FILED,CLEARED,CLOSED_NO_ACTION) and anotInfilter, using the realCaseStatusenum values from@prisma/clientinstead 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, andESCALATEDremain non-terminal — a case in any of those still gets new evidence attached, unchanged from before.Closes #393.
Test plan
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 asSAR_FILEDorCLEARED(parametrized), plus an explicit check that the filter'snotInlist contains every terminal status in the schema.npm test) passes: 112 suites / 1530 tests.tsc --noEmitandeslintclean.