This is an opinion question, and may have multiple differing answers that are all correct, but I'm going to try my best to answer it.
I think the justice system should declare mentally ill offenders not guilty, even if they are guilty of the crime, if their mental illness may have played a part in the offense. However, if there are mentally ill offenders whose mental illness had not played a part in the offense, they may be found guilty, but while sentencing them, the justice system must still take their illness into consideration.