The case was eventually conceded in January 2019 on the grounds the harassment complaints process was “tainted by apparent bias” due to the prior contact.
The admission raises further questions around why the Scottish Government continued to fight the judicial review despite this advice.
Mr Swinney said in a letter to the Salmond inquiry this was done due to “good public policy arguments and reasonable grounds”.
The concession of the judicial review led to costs of more than £500,000 to the taxpayer.
Mr Swinney said: “The documents confirm that, whilst reservations were raised about the judicial review following the identification of the issue of prior contact with the complainers in late October, there were good public policy arguments and reasonable grounds for the Government to continue to defend the judicial review and to seek a determination from the Court on the matters raised, until the events of late December 2018.”
The letter to the committee comes as Mr Swinney’s job hangs by a thread due to a looming no-confidence motion, submitted by the Scottish Conservatives and backed by all opposition parties.
They say that unless all the legal advice is released and published, they will push forward with a vote, most likely on Thursday.
Scottish Tory leader Douglas Ross said: “The legal advice that John Swinney claimed would exonerate the government actually confirms what everyone suspected.
"Recklessly continuing with the judicial review when it was doomed would clearly be a breach of the ministerial code. The public deserve to know exactly what mistakes were made.
"John Swinney is not getting away with releasing only the evidence he wants us to see. We will press ahead with the vote of no confidence until all the legal advice is published.”
It comes as Geoff Aberdein, Alex Salmond’s former chief of staff, released a statement on Twitter about the non-publication of his evidence to the committee.
He said he was “disappointed and dismayed” at the suggestion of “opposing camps” within the SNP, but the publication of his evidence was “entirely a matter for Parliament”.
Mr Aberdein said: “I was informed by clerks of the committee in January of this year that for legal reasons they had taken the decision not to publish my submission in any form.
"This position was reiterated to me by the clerks today and I will not put myself in a position of contravening these legal considerations.
"I am very disappointed and dismayed at the prominent narrative of ‘opposing camps’ as far as the SNP is concerned.
"That does not reflect my experience of advising the SNP and Scottish Government.”
The publication of the legal advice also follows revelations in the Scottish Sun that permanent secretary Leslie Evans may have destroyed her notes of a ‘secret meeting’ between her and the First Minister in November 2018.
The paper reports that testimony to a commission on diligence from Ms Evans stated that while she takes notes from meetings with the First Minister, she destroys her notebooks once they are full.