The high court has upheld ruling that prisoners cannot sue prison staff for money damages under religious liberties law.