The commission shall reimburse the secretary for all expenses incurred by the secretary in carrying out his or her duties and responsibilities pursuant to this chapter. However, a court may, if it finds that the secretary has acted arbitrarily or capriciously in restricting the activities or functions of the commission, relieve the commission of the responsibility for the payment of the secretary’s legal costs with regard to that action.