(3) a hearing, or a part of a hearing, for which the court issues a written order finding that allowing the hearing, or part of the hearing, to be open to the public would reasonably be expected to
- (A) stigmatize or be emotionally damaging to a child;
- (B) inhibit a child's testimony in that hearing;
- (C) disclose matters otherwise required to be kept confidential by state or federal statute or regulation, court order, or court rule; or
- (D) interfere with a criminal investigation or proceeding or a criminal defendant's right to a fair trial in a criminal proceeding; before ruling on a request under this subparagraph, the court shall give notice and an opportunity to be heard to the state or a municipal agency that is assigned to the criminal investigation or to the prosecuting attorney.