It is a mistake in logic, specifically the part where people see someone in an unfortunate situation and think "They must have done something to deserve that".
The fallacy isn't the idea that the world is just (it may or may not be), it's making the assumption that the just-world idea is actually true.
The fallacy isn't the idea that the world is just (it may or may not be), it's making the assumption that the just-world idea is actually true.