diff --git a/front/src/modules/activities/components/ActivityRelationPicker.tsx b/front/src/modules/activities/components/ActivityRelationPicker.tsx index ec16d93576..9addb8d854 100644 --- a/front/src/modules/activities/components/ActivityRelationPicker.tsx +++ b/front/src/modules/activities/components/ActivityRelationPicker.tsx @@ -19,6 +19,7 @@ import { RecoilScope } from '@/ui/recoil-scope/components/RecoilScope'; import { MultipleEntitySelect } from '@/ui/relation-picker/components/MultipleEntitySelect'; import { RelationPickerHotkeyScope } from '@/ui/relation-picker/types/RelationPickerHotkeyScope'; import { Activity, ActivityTarget, CommentableType } from '~/generated/graphql'; +import { assertNotNull } from '~/utils/assert'; import { useHandleCheckableActivityTargetChange } from '../hooks/useHandleCheckableActivityTargetChange'; import { flatMapAndSortEntityForSelectArrayOfArrayByName } from '../utils/flatMapAndSortEntityForSelectArrayByName'; @@ -86,7 +87,8 @@ export function ActivityRelationPicker({ activity }: OwnProps) { () => activity?.activityTargets ?.filter((relation) => relation.commentableType === 'Person') - .map((relation) => relation.commentableId) ?? [], + .map((relation) => relation.commentableId) + .filter(assertNotNull) ?? [], [activity?.activityTargets], ); @@ -94,7 +96,8 @@ export function ActivityRelationPicker({ activity }: OwnProps) { () => activity?.activityTargets ?.filter((relation) => relation.commentableType === 'Company') - .map((relation) => relation.commentableId) ?? [], + .map((relation) => relation.commentableId) + .filter(assertNotNull) ?? [], [activity?.activityTargets], ); diff --git a/front/src/modules/activities/hooks/useHandleCheckableActivityTargetChange.ts b/front/src/modules/activities/hooks/useHandleCheckableActivityTargetChange.ts index 8414642467..6c348fc630 100644 --- a/front/src/modules/activities/hooks/useHandleCheckableActivityTargetChange.ts +++ b/front/src/modules/activities/hooks/useHandleCheckableActivityTargetChange.ts @@ -70,7 +70,9 @@ export function useHandleCheckableActivityTargetChange({ }); const activityTargetIdsToDelete = activity.activityTargets - .filter(({ commentableId }) => !entityValues[commentableId]) + .filter( + ({ commentableId }) => commentableId && !entityValues[commentableId], + ) .map(({ id }) => id); if (activityTargetIdsToDelete.length)