Court of appeal rules on child in need status