I apologize if for any mistakes, I am not a trained programmer, just a hobbyist.
update for M3:
=INDEX(TEXTJOIN(", ", 1, IF(
(FILTER('Misc Data'!$B$38:$R$54,
REGEXMATCH('Misc Data'!$A$38:$A$54, JOIN("|", $F3, $G3)))=2)
(FILTER('Misc Data'!$B$38:$R$54,
REGEXMATCH('Misc Data'!$A$38:$A$54, JOIN("|", $F3, $G3)))=4),
TRANSPOSE('Misc Data'!$A$38:$A$54), )))