1）Tom went to the party with Mary yesterday.
2）It was Tom who/that went to the party with Mary yesterday.
3）It was Mary who/that Tom went to the party with yesterday.
Sentence 2 and 3 are emphatic sentences. In sentence 2, both "who" and "that" are appropriate. In sentence 3, some books say that only "that" is appropriate because we could use "who" if the emphatic element is a person and also functions as the subject of the original sentence (sentence 1), while some books say both "who" and "that" are appropriate.
I am wondering in sentence 3, whether "who" is correct or not.