In the sentence "Mary walked over to the boy, laughing at the joke.", who do you think is laughing? Just give your gut feeling, no need to worry about what grammar rules might apply.
I have already overthought this question, so I'm not going to explain the background unless someone asks me to in the comments. I'm just curious what instinctive sense other people have on it.