TEXTJOIN only when the condition is met?

Your formula works you just need to enter it as an array formula, hold ctrl + shift and press enter to make it an array formula. It should look like:

=ArrayFormula(TEXTJOIN(", ",true,if(B1:B6 = D1,A1:A6,"")))  

You could also use the filter function

=TEXTJOIN(", ",true,FILTER(A1:A6,B1:B6 = D1))

The if is just giving one result, not a series of them. You need:

=textjoin(" ,",true,arrayformula(if($B$1:$B$20=$D$1,$A$1:$A$20,"")))