I have used the below array formula before to get all ID=8 in a separate list but now I have a new problem that I hope can be solved in a similar way but I cannot really figure out how..

Array formula used to get all rows with ID=8 in a new list without gaps.
=INDEX(ID,SMALL(IF(ID=8,ROW(ID)-ROW($A$1)+1),ROWS(AF$28:AF28)))

Now I have the following sheet:

In column A i have all ID:s
In column B i have an argument, YES or NO.

What I want to do is to get a list of all ID:s in column A that are marked with YES in a new list without any gaps. How can I do this? As column B can change quite a lot I want this as an array formula so it automatically updates the new list.

The list of ID:s are around 600 rows if that matters.

Thanks for your help!