I can't think of any way that the customs officials could have known that he was going to do work unless he told them. It seems to me then that the naive stupid thing was not trying to enter on a tourist visa, but telling the officials that he wasn't really a tourist. When dealing with government officials, a little discretion can go a long way.