I think the way that is hidden is much of the problem.
I'm NOT a lawyer, and someone who has training in reading the law could/should make a comment on this, but it seems to me that the operative section was written as a long compound sentence. For several reasons that sentence is vulnerable to being misread.
American media writes in short sentences, so Americans, I suppose including border guards, tend to read writing in little snippets
Looking toward the end of the sentence set off in (II) there -is- language that talks about 'if' there is a likelihood of recurrence.
Unfortunately, it seems that turning the sentence into part of the US Code required the insertion of various identifiers to facilitate legal reference to special conditions or circumstance within each clause. the law. The sentence is also broken into sub-parts as it is laid out for printing...again seemingly to facilitate referencing different aspects of the law.
IMO, that complicates reading and understanding the sentence as it was originally written...which to me seems to include a conditioning statement which refers to both (I) and (II) rather than just (II). But again, I'm not a lawyer and I'm not familiar with editing rules or rules for interpretation of laws and regulations.
The spirit of the law would appear to be to require denial of entrance to persons who are in a state of mind where they would be dangerous to property, themselves, or others. I think it's unlikely that a Border Guard can technically achieve a psychological evaluation, but I can see how empowering a border officer to do so might be in the interest of the US and its residents.
The law certainly needs to be clarified for the border guards so that a past history of a long resolved mental crisis isn't a barrier to traveling through the US. I'm not sure if that is best done by an administrative ruling stating a specific interpretation or if it would be done by amending the law. In any case something should change.