Skip to content

Commit 8ec7eb2

Browse files
authored
Update trust.involved.ts
1 parent a922ae3 commit 8ec7eb2

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

src/utils/trust.involved.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -167,25 +167,11 @@ export const postTrustInvolvedPage = async (
167167
const appData: ApplicationData = await fetchApplicationData(req, isRegistration);
168168
moveTrustOutOfReview(appData);
169169

170-
const filterIndividualsInTrust = (trust: any) => {
171-
if (!trust.INDIVIDUALS?.length) {
172-
return; // Early exit if there are no individuals
170+
appData?.trusts?.forEach(trust => {
171+
if (Array.isArray(trust.INDIVIDUALS)) {
172+
trust.INDIVIDUALS = trust.INDIVIDUALS.filter(ind => ind.forename);
173173
}
174-
175-
trust.INDIVIDUALS = trust.INDIVIDUALS.filter(
176-
(individual: any) => Boolean(individual.forename) // Only keep individuals with a forename
177-
);
178-
};
179-
const filterTrustIndividuals = (trusts: any[] | undefined) => {
180-
if (!trusts?.length) {
181-
return; // Early exit if no trusts are available
182-
}
183-
184-
trusts.forEach(filterIndividualsInTrust);
185-
};
186-
if (appData?.trusts) {
187-
filterTrustIndividuals(appData.trusts);
188-
}
174+
});
189175
setExtraData(req.session, appData);
190176
if (isActiveFeature(config.FEATURE_FLAG_ENABLE_REDIS_REMOVAL) && isRegistration) {
191177
await updateOverseasEntity(req, session, appData);

0 commit comments

Comments
 (0)