Newly published court papers have revealed why former MP Natalie McGarry faced trial twice for embezzling funds from pro-independence groups.
She was found guilty of taking £25,000 from an SNP branch and the Women for Independence group.
McGarry had been jailed for the same offence in 2019, after pleading guilty.
But judges agreed to throw that case out after ruling there had been a miscarriage of justice in the "clearly prejudicial" proceedings.
McGarry had been dropped by her lawyer minutes before the case was called in April 2019, and was then given 10 minutes by the sheriff to decide on her plea with no representation.
She is now awaiting sentence having been tried and convicted of similar charges in the fresh jury trial.
The case dates back to 2015, the year McGarry was elected to the Westminster parliament for the Glasgow East constituency.
Women for Independence reported their former treasurer to the police for embezzlement, and the following year the SNP's Glasgow Regional Association followed suit and she was interviewed by police.
McGarry's legal team attempted to strike a plea deal with the Crown, but minutes before she entered the courtroom on 24 April, 2019, her lawyer told her he could not submit a guilty plea because he believed she was "pleading guilty as a plea of convenience and was not accepting her guilt".
He then told the sheriff that he was withdrawing from the case, and McGarry - who was "visibly upset and distressed" - was given minutes to decide what to do.
Appeal judges noted that she was left "in highly pressurised circumstances" with no opportunity to take legal advice.
McGarry then pleaded guilty to two charges, and when asked if she took issue with anything in the written narrative of the circumstances she said she did, but that "we are where we are".
The case was then adjourned for a week, and McGarry took on a new lawyer who applied to the court to have her guilty pleas withdrawn.
However, this was refused by the sheriff, who said McGarry was fully aware of what she was doing when tendering the pleas, and she was jailed for 18 months.
This was quashed following an appeal, and the reasons for that judgement have now been released after the conclusion last week of the second trial.
Judges found that McGarry was not properly represented, and that the sheriff was not made aware of how unprepared she was for trial or the extent of her mental health issues.
A psychologist had ruled she was fit to stand trial, but noted she had symptoms of depression as well as anxiety and panic disorders - having allegedly told a lawyer that she "would probably kill herself rather than go to trial".
The appeal judges said that "the pleas were tendered by the appellant in circumstances which were clearly prejudicial to her", and that a miscarriage of justice had occurred.
McGarry - who left parliament in 2017 - went on trial again in 2022.
She was found guilty of embezzling £19,974 while treasurer of WFI between April 2013 and November 2015, and £4,661 when she was treasurer, secretary and convener of the Glasgow Regional Association of the SNP between April 2014 and August 2015.
Sheriff Tom Hughes said McGarry had committed "a very serious breach of trust". She will be sentenced next month.