'The law doesn't use the word party'
Well, no. It uses the word "gathering", which is actually a whole lot easier to define. When you find yourself in a room with a group of people and a load of booze, making a speech and raising a toast to someone, that's pretty indisputably a gathering, and not one that is reasonably necessary for work.
The weird thing is that Johnson himself has conveniently forgotten the purpose of these restrictions. He may have thought that attending a leaving do was a nice thing to do, but the simple fact is that it didn't affect one iota anyone's ability to do their work in no. 10 - and the virus isn't going to give anyone a pass because they're doing something nice.