We must use SUBTOTAL and OFFSET in Office 2019 because it lacks the dynamic array formula in order to return an array of the MINIMUMS of each row to SUMPRODUCT. Add the following criteria to SUMPRODUCT after that:
=SUMPRODUCT((B2:B8="YES")*A2:A8,SUBTOTAL(5,OFFSET(C1:J1,ROW(C2:J8)-MIN(ROW(C2:J8))+1,0)))
One note, for me the numbers transferred as text not numbers. Make sure they are true numbers or this will not work.
For those with the Dynamic Array formula we can ditch the Volatile Offset:
=SUM(BYROW(ROW(A2:A8),LAMBDA(z,INDEX(A:A,z)*(INDEX(B:B,z)="YES")*MIN(INDEX(C:J,z,SEQUENCE(,COLUMNS(C:J),1))))))