Well, if you split the compound word to could not, your sentence would read, "It could not of happened that way." The subject does not agree with verb. Your sentence should read, "It couldn't have happened that way." I hope you learned something from this.