Complex sentence: When agreeing to spy on the other inmates, they were proven innocent, however when they discovered he was a spy, he was assaulted and needed to be hospitalized.
Split into simpler sentences: When agreeing to spy on the other inmates, they were proven innocent. However, when they discovered he was a spy, he was assaulted and needed to be hospitalized.