If the commissioner imposes a restriction on access to and use of legal reference materials by or legal assistance of a prisoner in a state correctional facility, a court may not enter an order giving relief to the prisoner unless the court first finds, by a preponderance of the evidence, that enforcement or application of the restriction hinders the prisoner from having access to and use of the legal reference materials or legal assistance
(1) in order to gain meaningful access to a court for the purpose of challenging
(A) the prisoner's conviction or sentence; or
(B) the conditions of the prisoner's confinement; or
(2) in circumstances in which a state court has specifically determined that a provision of the state constitution necessarily requires a prisoner to have access to and use of the legal reference materials or legal assistance.