This question already has an answer here:
Which of the following example sentences is correct? (one uses who and the other uses whom)
This has caused a problem for students who, up until recently, were in good shape.
This has caused a problem for students whom, up until recently, were in good shape.
I am aware I should use whom when it's the object of the preposition, but I'm confused about how to analyze the grammar of these sentences.