It was not illegal. Businesses are not required to charge sales tax in states where they have no operations.
If you or I aided and abetted widespread tax evasion, we would get our asses handed to us in court.
The 5-4 majority in 2018 included two justices who were part of the unanimous holding in 1992 (Anthony Kennedy and Clarence Thomas), voting to overturn their own decision from a quarter century before.