Psalm 94:12 Blessed is the man whom thou chastenest, O LORD, And teachest him out of thy law;
God disciplines those that are His. That should make us happy. But this verse teaches us another reason to be happy. He is teaching us when He disciplines us. It is not just punishment by any means. It is a tool to teach me to obey Him. He disciplines me so that I will understand Him and truth better.
He disciplines me so that I will grow spiritually and live out the life that He has called us to live. So when you are being disciplined you should be happy the verse says!