Is this sentence correct:
"There had to have been a reason why she didn't want to talk to me, and I prayed it was because she was trying to protect Sachs."
I think it has to be either "There had to be a reason ..." or "...why she hadn't wanted to talk to me".
"There had to have been a reason" is fine. It is similar in meaning to there must have been a reason. The speaker or writer is speculating on something that has already happened. (The verb tense is, I think, past perfect progressive.)
Perhaps somebody else will offer an additional comment or two. In any case, that usage is perfectly fine.