In one of my math courses in university, we studied a problem where a number of people show up to a party, wearing hats. Each left with the wrong hat. I am pretty sure that there was some specific name for this problem.

What is the problem called? I would like to use this to calculate some Secret Santa matchings, so that nobody gets matched with themselves.