The government knew there were some dangerous individuals among that population (a small minority) but they couldn't reveal it because then the Japanese government would learn that we had broken their code.
In World War I, Australia and New Zealand put immigrants from Austria-Hungary in concentration camps, even those who had become naturalized and were willing to fight for the British Empire.
You are correct on the codes. See my previous post about Magic, it’s a great resource on the subject.