The commission may investigate any matter that affects the cost or quality of transportation of oil or gas in this state by pipeline carriers or affiliated interests or of related services and may ensure compliance by pipeline carriers and their affiliated interests with the provisions of this chapter. Investigations may be public, nonpublic, or both. In conducting investigations, the commission may compel the attendance and testimony of witnesses and the production of records and testimony before the commission or its designee. In the course of an investigation, the commission may exclude from attendance at the taking of investigative testimony all persons except the person compelled to attend, that person's attorney, members of the commission or the commission's staff, and a person authorized to transcribe the proceedings. Following an investigation and after providing reasonable notice and opportunity for hearing, the commission may institute proceedings to determine whether unreasonable practices have occurred, whether expenditures have been imprudently incurred, the costs of those practices or expenditures, and whether a pipeline carrier and its affiliated interests are in compliance with this chapter. Following such a determination, the commission shall take appropriate action to ensure that neither the direct nor indirect costs of any unreasonable practices or imprudent expenditures are included in any tariff or rate of a pipeline carrier or are borne by the public or the state.