Judges have ruled "compatibility" claim was lawful, overturning an earlier High Court judgement.