Could is sometimes called the "remote" form of can. Sometimes it acts like a simple past tense:
Yesterday I couldn't see the problem, but today I can.
≅ Yesterday I wasn't able to see the problem, but today I am.
but sometimes it acts like a conditional:
I couldn't do it if I tried.
≅ I wouldn't be able to do it if I tried.
or emphasizes the vagueness of a possibility:
Anything could happen between now and November.
≅ Anything can happen, maybe, between now and November.
and sometimes it's simply more polite:
Could you pass the salt?
≅ Can you pass the salt, please?
In your example, both Rowling's "couldn't you have told" and your "couldn't you tell" would be correct. In your "couldn't you tell", could is acting as a past tense. In Rowling's "couldn't you have told", it's have that's providing the past-tense sense, and could is serving a less well-defined role. It could be interpreted as a conditional:
Why couldn't you have told us all this yesterday when we were all awake?
≅ Why wouldn't you have been able to tell us all this yesterday when we were all awake?
≅ You decided not to tell us all this yesterday when we were awake. Why? What made you think you wouldn't be able to?
. . . but for language-learning purposes, I think it might be better to think of could have as an idiom, and not try to unpack it too much. To ask why something "couldn't have" happened is to invoke the idea of alternate world where it did, and could's vague conditional sense is perfect for that.