Fix #9363: Code hints popup dismisses prematurely

I moved the logic to restore the collapsed files to the template, so that we don't need to toggle them after the results UI is rendered.
We could and we can remove the toggle classes for the expanded class.