- relative clause formation can extract relative pronouns from far away in the clause
(several candidatesᵢ whoᵢ had the qualifications)
(several candidatesᵢ whoᵢ he thought had the qualifications)
(several candidatesᵢ whoᵢ she said he thought had the qualifications)
- but they can't extract them from islands; add that and it becomes ungrammatical.
*(*several candidatesᵢ whoᵢ he thought that had the qualifications)
It's complicated. The reason whom is wrong is that it's not an object; it's a subject.
3 main verbs, therefore 3 clauses:
Note that (3) is subjectless, though it's clear that its subject refers to whoever who refers to.
So the question is, why is who correct? Because it really is correct here, and whom is incorrect.
Let's take a look at some other sentences. Let's start be deleting "he thought", producing
Note that who is in fact the subject of had in this relative clause; whom would be wrong.
Clause (2) is tensed (it's in past tense; it's not an infinitive or gerund), it's a complement clause (the clause is the direct object of think), and it starts with the complementizer that, which is optional here, as (2') shows.
So what? Well, one more fact about tensed complement clauses:
And two more facts about relative clauses:
What that adds up to is that the relative pronoun heading a relative clause may come from indefinitely far away, and does not necessarily have anything to do with the clause that happens to be at the beginning.
In this case, the I think part is essentially an adverb and adds no information, but instead qualifies the speaker's assertion. It plays no part in the rest of the relative clause, and its object is a whole clause, not a pronoun. Who was extracted from the subject position of that object clause and moved to the front by relative clause formation.