Most grammar books try to explain the English tenses as if they were mathematical formulas - there's correct and there's not.
The problem is that the English tenses (and the English grammar, in general) are not mathematical formulas, and many times more than one tense fits the context.
there are cases where some specific tense is simply wrong for a specific context, like
I haven't seen her last week
we don't use the present perfect tense with a finished time period. not because it's "incorrect" but merely because it doesn't make any sense: the present perfect has many roles, discussing some action in some finished time period isn't one of them.
But this is a very specific case, and many times, it's not about "what's right" or "what fits here better" but it's more about "what do I want to emphasize"?
the Past Perfect emphasizes (among other usages) the fact that one action had finished (or hadn't finished) before another action in the past. the keyword here is emphasizes.
Don't look at me. the house had been a mess way before I got here.
in this case, I want to emphasize the fact the messiness of the house existed before I got there. I used the Past Perfect.
Usually, we can understand from the context what happened before what, and emphasizing the order of them is just redundant, or the order doesn't matter to begin with.
We thought that Joe didn’t go to the museum with the rest of the class.
Here, it's kind of obvious we though about Joe after he went (or didn't go) to the museum, and also, we don't care to much if our thinking happened before he went to the museum, it doesn't really matter here.
when more than one tense fits the context, think what you want to emphasize. when you hear a speaker speaks, think what he or she wants to emphasize by their tense choosing.