It wasn't just a pact of non-aggression. They divided Poland between themselves! France and Britain abandoned Czechoslovakia to avoid a war, USSR made an alliance with Nazi Germany to begin one.
And USSR and the US were on the same side because they were attacked by allied countries (Germany and Japan), they didn't chose one another. Stop your historical revisionism.
Still, the USSR considered that an alliance with Nazi Germany was ideologically acceptable, even if they were not aligned. Because the only true ideology of USSR was to maintain its leaders in power, Marxism was just a facade. And that's will always ultimately the case with authoritarian governments.