This is way more complicated than most of the comments imply. It's not only about your taxes, but about the company's payroll taxes, and also other regulations and services. First of all, it's a unique thing about software engineering that you can get away with working while living in another country and pretend that "well the work is for a US company and I pay taxes in US so it's ok" or "I don't have a work visa in Japan[1] but I'm working for an American company from Tokyo so it's ok". If your work is swinging a hammer, it's more obvious, but in reality tax generally treaties specify that work done in the country you reside in, whether by hammer or laptop, is taxed in that country. Because you enjoy the services from that country.
One example is raising kids in country A while you are employed by country B. OK, you pay sales tax and maybe property tax in country A but country A is expecting payroll tax to help pay for education, and healthcare fees based on your income to help pay for healthcare.
Another example is insurance. If you work for google you can probably sue them when your WFH desk bought with inadequate WFH allowance collapses and breaks your ankle. But does google's insurance cover the case of working in your summer home in Iran, or is able to make a payment to an Iranian hospital? Not likely. At least it's a moot point compared to the embargo violation and export control violation that now comes to light.
Another example is just legal stuff in general. "Work" in US and live in Spain? What's the legality of the NDA you signed? What's the process to fire you? Who knows, but a company sure doesn't want these uncertainties times the number of countries its remote workers are located.
Mature companies know all of this and put rules in place and either open a proper office when it's justified or hire a middleman company who then hires the remote worker as a contractor.
[1] I use US and Japan specifically because I just finished a 10 year stint in Japan and well, it's common online to see Americans living in Japan on a marriage visa or something, trying to get remote/American salaries and totally missing the basic requirement: work done in Japan is taxed in Japan and also subject to other Japanese regulation. So not only can you be in trouble for not paying taxes in Japan, your company can be in trouble when it realizes that by paying an employee in Japan, it is also bound by Japanese labour law. My understanding is that this works similarly for most country pairs.
There are also additional issues with this arrangements.
For example, social security payments. Pension plans, etc.
A simple example, Israel has mandatory pension plan requirement for all employees. If you are working remotely in Israel "as if in the US", you are now opened to a whole bunch of interesting questions. Employer isn't aware of that, in this scenario, so isn't paying the pension.
That creates:
* criminal liability for the company
* criminal liability for the management team personally
* the company is assumed to be "self-insured" and basically has to act as the pension provider for the employee.
You fall down and become invalid at the age of 27? The pension insurance will pay for that. Which is basically the company. Then you have to pay 60+ years of pension payments to that employee.
And that is _one_ aspect of this issue.
Others are related to laws. What is the minimum wage? How do you compute the allowable number of hours and overtime pay?
For fun, let's say that you are working for a few years in this mode. The employee then sues the company for overtime pay (200%) because that is the law where they are working.
Firing someone, also, is a totally different process across jurisdictions. In Israel, you have to pay a month's salary for every year that the employee worked for you (based on the last 3 - 6 months).
You have to fire a senior guy that worked for you for 6 years? Prepare to pay immediately a big chunk of money.
Also, have fun with _another_ criminal liability (for the company & leadership) because you didn't pay insurance for this scenario.
The company in this question is going to be absolutely against this sort of exposure.
For that matter, it isn't even legal only that is going to object. If you are a public company, you need to put things like "liabilities in case we have to fire people" in the balance sheet. The CPA is going to have a field day with all those undisclosed issues.
One example is raising kids in country A while you are employed by country B. OK, you pay sales tax and maybe property tax in country A but country A is expecting payroll tax to help pay for education, and healthcare fees based on your income to help pay for healthcare.
Another example is insurance. If you work for google you can probably sue them when your WFH desk bought with inadequate WFH allowance collapses and breaks your ankle. But does google's insurance cover the case of working in your summer home in Iran, or is able to make a payment to an Iranian hospital? Not likely. At least it's a moot point compared to the embargo violation and export control violation that now comes to light.
Another example is just legal stuff in general. "Work" in US and live in Spain? What's the legality of the NDA you signed? What's the process to fire you? Who knows, but a company sure doesn't want these uncertainties times the number of countries its remote workers are located.
Mature companies know all of this and put rules in place and either open a proper office when it's justified or hire a middleman company who then hires the remote worker as a contractor.
[1] I use US and Japan specifically because I just finished a 10 year stint in Japan and well, it's common online to see Americans living in Japan on a marriage visa or something, trying to get remote/American salaries and totally missing the basic requirement: work done in Japan is taxed in Japan and also subject to other Japanese regulation. So not only can you be in trouble for not paying taxes in Japan, your company can be in trouble when it realizes that by paying an employee in Japan, it is also bound by Japanese labour law. My understanding is that this works similarly for most country pairs.