For your question of building an IN ( ) list, there are a few options that you can find discussed in the following post from 2022.
I suggest reading that whole thread through ( as back then I was still learning about this stuff too and my understanding evolved during that thread thanks to @ipazin ), and also try the workflows that are attached within the posts. I think it should give ideas that cover your question. If anything is unclear, feel free to ask further…