I am using this array formula which works fine:
=IF(ROWS(K$62:K62)>COUNTIF(accounts_table[§],"=P"),"",INDEX(accounts_table[Account Name],SMALL(IF(accounts_table[§]="P",ROW(accounts_table[§])-ROW(Ledger!$H$17)+1),ROWS($K$62:K62))))
however I need to add another OR condition...