Here is a post written by @ThinhDinh
Tutorial: Arrayformula in Google Sheets, good practices & how to overcome Arrayformula restrictions with scripts