One day the Prophet, peace be upon him, was on a journey with his Companions. Each one of the Companions had with him his belongings including weapons, sleeping mats and food. They stopped over at a place and a man amongst them fell asleep. His friend turned to a rope he had and took it jokingly. When the man woke up and found the rope missing from his belongings, he was terrified and began looking for it. Thereupon the Prophet said, "It is not allowed for a Muslim to frighten another Muslim." (Abu Dawud)
Similar is the case with someone who jokes with you thinking that you will be happy, whereas in reality, he only harms you, or even worse, fills your heart with fright and anxiety. For instance, he notices that you have just parked your car outside a grocery with the engine running, so he comes and drives off in your car, causing you to think that your car has been stolen - obviously as a joke. The one on the receiving end of such jokes may respond courteously and may even laugh at the joke, but the fact remains that the joke was still cruel.