diff --git a/frontend/benefit/handler/src/components/applicationList/ApplicationList.tsx b/frontend/benefit/handler/src/components/applicationList/ApplicationList.tsx
index 98b9ac6ce4..01b6da59d9 100644
--- a/frontend/benefit/handler/src/components/applicationList/ApplicationList.tsx
+++ b/frontend/benefit/handler/src/components/applicationList/ApplicationList.tsx
@@ -109,6 +109,19 @@ export const renderPaymentTagPerStatus = (
$TagWrapper>
);
+const parseAhjoError = (ahjoError: AhjoError): JSX.Element[] => {
+ if (Array.isArray(ahjoError.errorFromAhjo))
+ return ahjoError.errorFromAhjo.map(({ message }) =>
{message});
+
+ if (
+ typeof ahjoError.errorFromAhjo === 'object' &&
+ ahjoError.errorFromAhjo.message
+ )
+ return [{ahjoError.errorFromAhjo.message}];
+
+ return [{String(ahjoError.errorFromAhjo)}];
+};
+
const ApplicationList: React.FC = ({
heading,
status,
@@ -177,13 +190,7 @@ const ApplicationList: React.FC = ({
Ahjo, {convertToUIDateAndTimeFormat(ahjoError?.modifiedAt)}
-
- {ahjoError?.errorFromAhjo?.map
- ? ahjoError?.errorFromAhjo?.map(({ message }) => (
- - {message}
- ))
- : ahjoError?.errorFromAhjo}
-
+ {parseAhjoError(ahjoError)}
$ActionErrors>
)}
diff --git a/frontend/benefit/shared/src/types/application.d.ts b/frontend/benefit/shared/src/types/application.d.ts
index a0e36d73b3..9db4e7c6d4 100644
--- a/frontend/benefit/shared/src/types/application.d.ts
+++ b/frontend/benefit/shared/src/types/application.d.ts
@@ -266,13 +266,13 @@ export interface DecisionProposalDraft {
}
export interface AhjoError {
- errorFromAhjo: ErrorFromAhjo[];
+ errorFromAhjo: ErrorFromAhjo | ErrorFromAhjo[];
modifiedAt: string;
status: string;
}
export interface AhjoErrorData {
- error_from_ahjo: ErrorFromAhjo[];
+ error_from_ahjo: ErrorFromAhjo | ErrorFromAhjo[];
modified_at: string;
status: string;
}