I agree with you in most contexts, but "illegal activity (in the country of service)" is a tough one in the context of an invasion, a territorial dispute, or international espionage.
Before the current war, Hamas was the governing authority in Gaza, despite the Palestinian Authority being the internationally recognized one. Regardless, whether the surveillance was legal under Israeli law doesn't seem like the correct standard.