What was the exact solution to this in the end? I am having the same problem.
I tried changing the logic AND/OR as you described but it wasn’t enough.
Then you should get all the product variations and if at least one has instock AND size M , do not add it here – https://c2n.me/481YUzQ.png
So how do I do that? To me this is something essential for filtering by variation and “in stock”.