Let me put it this way: Not every mental illness is indicative of insanity, but all insanity is indicative of mental illness.
Lots of people have mental illnesses, but they never set foot in a nut house - remember, things like depression, anxiety, autism, and phobias are forms of mental illness, but having them does not mean the patient is crazy.
I think a person becomes insane when they become a danger to others or they are beyond rehabilitation; sociopaths, I feel, are insane, because they fit perfectly into both of the aforementioned categories. Sociopaths can kill people and feel no remorse, and they absolutely cannot be 'healed' because their ability to manipulate and twist things is beyond what any medicine or therapy could reverse.
I wouldn't say bipolar disorder qualifies a person as being insane because BPD is more of the person being a danger to themselves than to others...and frankly, I don't care if a person wants to shoot up, never sleep and then end the day with killing themselves.
Some people may have numerous mental illnesses, and the combination of those conditions may turn them into someone who is dangerous all-around or who will never be able to function outside of a mental hospital. I would also consider that to be insanity as well.