Skip to content

Commit

Permalink
10556-bug: account for irs superuser
Browse files Browse the repository at this point in the history
  • Loading branch information
Mwindo committed Nov 19, 2024
1 parent 95e6f3d commit f9231c3
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions shared/src/business/useCases/getCaseInteractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import {
isAssociatedUser,
isUserPartOfGroup,
} from '../entities/cases/Case';
import {
INITIAL_DOCUMENT_TYPES,
ROLES,
} from '@shared/business/entities/EntityConstants';
import { NotFoundError, UnauthorizedError } from '@web-api/errors/errors';
import { PublicCase } from '../entities/cases/PublicCase';
import {
Expand Down Expand Up @@ -50,9 +54,7 @@ const getSealedCase = ({
}

if (!User.isInternalUser(authorizedUser.role)) {
caseRecord.docketEntries = caseRecord.docketEntries.filter(
d => d.isOnDocketRecord,
);
filterDocketEntriesNotOnDocketRecord({ authorizedUser, caseRecord });
}

if (isAuthorizedToViewSealedCase || isAssociatedWithCase) {
Expand All @@ -74,9 +76,7 @@ const getCaseForExternalUser = ({
isAssociatedWithCase,
isAuthorizedToGetCase,
}) => {
caseRecord.docketEntries = caseRecord.docketEntries.filter(
d => d.isOnDocketRecord,
);
filterDocketEntriesNotOnDocketRecord({ authorizedUser, caseRecord });
if (isAuthorizedToGetCase && isAssociatedWithCase) {
return new Case(caseRecord, { authorizedUser }).validate().toRawObject();
} else {
Expand Down Expand Up @@ -211,3 +211,18 @@ export const getCaseInteractor = async (
);
return caseDetailRaw;
};

const filterDocketEntriesNotOnDocketRecord = ({
authorizedUser,
caseRecord,
}: {
caseRecord: RawCase;
authorizedUser: AuthUser;
}) => {
caseRecord.docketEntries = caseRecord.docketEntries.filter(
d =>
d.isOnDocketRecord ||
(d.documentType === INITIAL_DOCUMENT_TYPES.stin.documentType &&
authorizedUser.role === ROLES.irsSuperuser),
);
};

0 comments on commit f9231c3

Please sign in to comment.