Immigration officials bungled visa details of a man whose marriage to a "high profile" Kiwi had fallen apart, leaving him facing the prospect of immediate deportation.
The strange case of Immigrant X has now seen Immigration NZ deny any records relating to the attempted deportation exist even though one of its officials turned up to serve a Deportation Liability Notice with two police officers to arrest the man.
It was only intervention by immigration law specialist Deborah Manning which halted the plan to put the man him on a plane out of the country.
Immigrant X came to New Zealand five years ago with his high-profile partner of 10 years and their three children.
His immigration status came into question after his partner ended the relationship and made multiple complaints to police alleging physical - and later sexual - violence.
None of the parties can be named because they remain locked in a Family Court dispute over his access to their children and rights to relationship property.
• Immigration New Zealand budget blowout kept overstayers in NZ
• Immigration NZ apologises for deporting alleged victim of serious crime
• Judge says mother 'reprehensible' in case of 'missing' girl found in NZ
• Family face deportation due to father's crimes
The attempted deportation came in June 2017 when the man was seeking a discharge without conviction on a charge of assault and three breaches of protection order after court hearings on complaints made by his former partner.
The man was acquitted of a string of charges brought by his wife, including a claim of rape.
Manning said she was at the Hamilton court for the hearing as she had provided an affidavit explaining his immigration status.
When she saw an Immigration NZ compliance officer enter the court with two police officers, she approached the man and asked why he was present.
When told he was there to serve a legal order for deportation, Manning said she explained her client had a valid visa to allow Family Court proceedings to be heard.
The compliance officer refused to provide a copy of the legal order - a Deportation Liability Notice - "did not care about her opinion" and "did not have to explain himself", she said.
Documents show Manning sought an urgent High Court hearing to put a halt to it and called the official's boss.
Having contacted the manager, it was discovered Immigration NZ was basing its deportation on an incorrect understanding of Immigrant X's immigration status.
Manning was told Immigration NZ had believed his visa - which had months left to run - was to attend criminal court and not Family Court.
Manning has now sought intervention by associate Minister of Immigration Kris Faafoi because of concerns over handling of the case.
In a letter to Faafoi, she said the Immigration NZ compliance officer was acting in an "unlawful" way. She said "individuals cannot be arrested, detained and deported without proper paperwork or legal authority".
She wrote to the Minister saying: "It also confirms what I consider has consistently been a hardline attitude of Immigration NZ to (Immigrant X) since his marriage break up with a high-profile New Zealander."
Manning said it showed Immigration NZ "were willing to take extreme and on the face of it unlawful actions in their attempt to ensure (Immigrant X) was deported from this New Zealand".
She said she had since sought through the Privacy Act copies of information relating to the Deportation Liability Notice only to be told no such legal order had ever been created and no paperwork existed.
Immigration NZ compliance and border manager Peter Devoy said the compliance officer was unaware Immigrant X had a valid visa for Family Court issues.
Devoy said the official had gone to court to serve a Deportation Liability Notice which had not yet been fully completed. It had been drafted on a pad used by compliance officers who were out of the office but had yet to be "authorised" by the official.
He said it "was not completed" after Manning "brought further information into play". As a result, it was considered to have no legal force or to have ever been created.
Devoy said if Manning had not been present then Immigrant X would have been taken into custody. However, he said the process allowed for a lawyer to be called which would alerted Immigration NZ officials to Immigrant X's valid visa and halted the deportation.
A spokeswoman for police said officers were present because they had been asked to help with a Deportation Liability Notice. "Two uniformed staff attended court but on arrival were told they were not required."
She said the cooperation agreement with Immigration NZ allowed police to help with removal orders "where it has been established that an individual is unlawfully in New Zealand".
Information seen by the NZ Herald shows police and Immigration NZ exchanged information about the case. Documents show police made immigration-related inquiries about the man and passed information learned to his former partner.
Documents also show his former partner passed on the name and phone number of a high-ranking National Party official, asking the person be contacted about the case.
A complaint to the Independent Police Conduct Authority over the communication was knocked back. Complaints about contact with Immigration NZ were also rejected.
Police were told by the IPCA officers should apologise for making inquiries where the man worked. The man was released from his job a short time later.
The IPCA found an apology also should have been made about "inappropriate comments" about the man while speaking to one of his lawyers.
Data obtained by Manning showed Immigrant X's Immigration NZ file had been accessed by a Beehive staffer 243 times in nine months. The Beehive staff member was a close aide to former associate Immigration Minister Scott Simpson.
In answer to questions about the Beehive access of the man's file, an Immigration NZ official said the high-profile of the man's former partner required access as a result of media queries.
A search of media archives shows no stories have been printed or broadcast about the case.
Simpson said the number of times the file had been accessed "surprises me" although he could not speculate as to why it was necessary.
He said he did not remember the details of the case.