I am using react-admin framework. I am creating an intersection of two arrays that should return one or multiple elements if the conditions return true. However the last condition gets skipped for some reason.
const filterWithTags = response.docs.filter((doc: any) => doc.hasOwnProperty("tags") && doc.tags.length > 0 && (tags as any).filter((tag: any) => doc.tags.includes(tag)));
This code returns only elements that match the first two conditions (hasOwnProperty and length> 0). I need it to continue to the includes condition as well.
Any ideas what Im doing wrong?
Thank you in advance