If a court finds a county liable as a result of acts or omissions by any official or employee in connection with the requirements of this chapter or any policies adopted pursuant to this chapter, then the county shall have a right of action for reimbursement against the official or employee whose conduct resulted in liability for the county not covered by insurance, where the conduct of the official or employee was intentional and knowing and constituted illegal behavior in the workplace. For purposes of this section, the words “intentional” and “knowing” have the same meanings as defined in §39-11-302. An official's or employee's conduct shall not constitute knowing or intentional illegal conduct in the workplace if the conduct was based on the written advice or opinion of the county attorney or the official's or employee's legal counsel.