Bosses at the Scottish Courts and Tribunal Services admitted making the error and breaching Welsh’s human rights in how he was wrongfully detained.

Lawyers for both Welsh and the Scottish Courts and Tribunals Service addressed Sheriff Fergus Thomson at proceedings in Edinburgh Sheriff Court last year.

Legal arguments centred on how much Welsh should receive in compensation. His lawyers believed he should receive £10,000 while court bosses argued the compensation should be £1,500.

In a written judgement, Sheriff Thomson said that Mr Welsh had a “lengthy record of periods of detention, both before and after the events of December 2023.”

He concluded that this should be reflected in how much he should receive in compensation.

Sheriff Thomson wrote: “The pursuer was wrongly detained for a period of seven days. It is accepted that he suffered no element of initial shock.

“He had not been wrongly arrested. His initial, short period of custody had not been unlawful. His circumstances were such that he was wholly familiar with the custodial setting.”

However, he then added that the Scottish Courts and Tribunals Service had acted unlawfully in detaining him, and that an award of £3,325 would be appropriate.