I've spoken to an H1B lawyer about this, You can actually monetize your online work, just as long as the freelance company is not American. You can start up a limited company in your home country and get paid into a bank account there.
Lawyers can give bad advice, and you need to triple-check non conventional advice. I used a lawyer who is really popular with YC companies. He gave me really bad advise, none of it worked eventually and I had to leave US eventually.
Be very conservative and careful when dealing with Immigration laws. Especially with the current environment.