The apostles left the Sanhedrin, rejoicing because they had been counted worthy of suffering disgrace for the Name. Acts 5:41
If the definition of “Joy/Rejoice” is intense gladness, rapture, delight, exult, make merry, etc. Chambers Dictionary), then it is ludicrous for the apostles who were beaten publicly and disgraced to rejoice. What is the secret for their joy? Recall that these same apostles a few weeks earlier were disappointed in Jesus who did not fight to establish the expected kingdom. When He was arrested, they all ran away. They watched Him die on the cross and gave up all hope of Him being the Messiah. They had to remain behind closed doors because of shame and fear of arrest by authorities.
Two things transformed the apostles: The resurrection and the coming of the Holy Spirit.
They now believed in their cause because of the resurrection and could boldly stand because of the Holy Spirit. Part of the package of being a Christian is persecution and suffering. “But rejoice in as much as you participate in the suffering of Christ … (1 Pt. 4:13); “Consider it pure joy, … when you face trials …” James 1:2. Jesus taught the same truth in the beatitudes Matt. 5:11,12. Joy is a gift of the Holy Spirit and no circumstance can affect it.
Even when things go bad and we are not happy, we will still have joy inside of us.