I don’t know all the details, and it’s possible the terminated employee had been walking on thin ice for some time before this incident.
But if this is really the only reason for his dismissal, well… I thought the joke was rather obvious. Most people who spotted the joke probably got a laugh out of it, and those who DIDN’T get the joke probably wouldn’t have complained.
The proper response from the boss would have been, “Ha ha, very funny. Now, don’t do that again!”