Maybe it’s a subordinate clause lesson, because that’s the key here.
From the June 2021 Scientific American, page 62:
In Lisbon, Portugal, the social centers Disgraça and RDA69,
which strive to re-create community life in an otherwise highly
fragmented urban situation, reached out with free or cheap food
to whoever needed it.
Last line. Shouldn’t that be “to whomever…”? After all, “to” is a preposition, so we should use the objective case, right? Nope.
Here’s the rule:
Go from the inside to the outside.
What’s inside the prepositional phrase? A noun clause! And “who” (well, “whoever”) is the subject of “needed,” so it gets the nominative case!
So there you have it. Sometimes you can say “to who.”