diff --git a/client/src/app/pages/assessment/components/assessment-actions/components/assessment-actions-table.tsx b/client/src/app/pages/assessment/components/assessment-actions/components/assessment-actions-table.tsx index eb40ab7f79..9ef0175551 100644 --- a/client/src/app/pages/assessment/components/assessment-actions/components/assessment-actions-table.tsx +++ b/client/src/app/pages/assessment/components/assessment-actions/components/assessment-actions-table.tsx @@ -24,6 +24,23 @@ const AssessmentActionsTable: React.FC = ({ const archivedQuestionnaires = questionnaires.filter( (questionnaire) => !questionnaire.required ); + + const nonRequiredQuestionnaireIds = questionnaires + .filter((q) => !q.required) + .map((q) => q.id); + + const relevantAssessmentIds = ( + application?.assessments || + archetype?.assessments || + [] + ).map((a) => a.id); + + const filteredArchivedAssessments = assessments.filter( + (assessment) => + nonRequiredQuestionnaireIds.includes(assessment.questionnaire.id) && + relevantAssessmentIds.includes(assessment.id) + ); + return ( <> = ({ isFetching={isFetchingQuestionnaires || isFetchingAssessmentsById} tableName="Required questionnaires" /> - - + {filteredArchivedAssessments.length === 0 ? null : ( + + )} ); };