By Chinua Asuzu
Who functions as the subject of a verb (including auxiliary verbs) or the complement of a linking verb.
Here’s who as the subject of a verb: Please call the associate who prepared that prospectus. This is another example: The association engaged an attorney who they think can represent them effectively. (who is the subject of can, they think being parenthetical).
Here’s who as the complement of a linking verb: She knows who she wants. (wants links the subject she to the complement who).
Whom functions as the object of either a transitive verb or a preposition.
Here’s whom as the object of a transitive verb: Kome Oruade is the brilliant attorney whom I mentioned in the Acknowledgments (_whom is the object of mentioned).
Here’s whom as the object of a preposition: Mustafa Ibrahim is the accountant to whom I owe much gratitude (whom is the object of the preposition to).
For who and whom, sometimes you can flip the sentence around, answer it if it is a question, or somehow try to substitute he or him for who or whom.
If you would use him in the sentence, then whom is correct.
Alternatively, if you would use he, you need to use who.”
Let’s try this together: should it be Who did you invite? or Whom did you invite? Let’s answer the question: I invited him. So, the correct question is Whom did you invite?
Chinua Asuzu, Learned Writing, Partridge, 2019, 227.