This is a good question! I remember this kind of situation happening to me as well in Soulsilver.
I may be wrong, seeing as I'm referencing from memory, but I think the attack is aimed at the last Pokemon who hit Wobbuffet, and only calculates the damage dealt by said Pokemon.