Below is a sentence from a light novel. (The context of the sentence is that a guy is traveling on a bus and the sentence is from his inner monologue about the congestion inside the bus.)
「そして気が付くと、仕事に追われフラストレーションを溜めたサラリーマンが、ついうっかり痴漢しちゃおっかな?と間違いを覚えてしまいそうなほどに車内は混雑している。」
I couldn't understand the part 「…間違いを覚えてしまいそう…」, so I asked a friend from Japan. She did some explanation, but I couldn't understand it very well since she did it in Japanese as well. But she said that she hadn't heard it before.
I also asked this in another Q&A platform, and someone from Japan said to me "I have never heard such Japanese. You shouldn't imitate the language that stupid Japanese people use." And another Japanese person said that it may just be a typo or mistake of author.
Is this an incorrect sentence? If it is correct, what is the translation of it? And what does 「…間違いを覚えてしまいそう…」 mean in this context?
Thank you.