Is the following sentence gramatically correct?
I didn't understand what he wants to tell you.
I think that it expresses that at some time in the past I didn't understand what he still wants to tell you at the moment of speaking. Am I right?
Essentially, you are correct about how the tenses are being used.
It's more understandable if you put it in context:
John's about to show up. He wants to tell you something. He discussed it with me a while ago. At first, I didn't understand what he wants to tell you. But now I do. You should hear him out and consider his words.
Barring that kind of context, it's certainly an unusual way of phrasing things. However, it's grammatical.