It was late on a Friday evening and I was about to head home from the ABC's Beijing office when the telephone rang.
On the other end of the line was a man from the Central Cyberspace Affairs Commission.
He refused to give his name but insisted one of the ABC's Chinese staff write down the statement he was about to dictate.
The man told us our reporting had "violated China's laws and regulations, spread rumours and illegal, harmful information which endangered state security and damaged national pride".
It was August 31, 2018, and I had been the ABC's China bureau chief since January 2016, working alongside reporter Bill Birtles.
Three weeks earlier the ABC's website had been suddenly banned in China and ever since I had been pushing for an official reason why. The telephone call came, and there it was.
But the call also marked the beginning of something else: more than three months of intimidation until my family and I were effectively forced to leave China.
They wanted me to know they were watching
I am telling this story for the first time. After my departure from China I was reluctant to report what had happened because I did not want to harm the ABC's operations in China, put staff at risk or threaten the chances of my successor as bureau chief, Sarah Ferguson, being granted a journalist's visa to China.
But all that changed with the expulsion of Birtles and Mike Smith from the Australian Financial Review this month.
My story — which occurred two years earlier — suggests there is more to their actions against foreign journalists than tit-for-tat reprisals as the Chinese portray it.
The fact is that every foreign journalist in China is under surveillance. But tracking of my activities picked up significantly after that Friday night phone call.
There is the kind of surveillance the Chinese government wants you to know about. When I was reporting on the mass detentions of Uyghurs in Xinjiang, for example, the ABC team was surrounded by about 20 security officials, followed by midnight knocks on our hotel room doors and questioning about our daily activities.
But there is also the hidden cyber surveillance and occasionally I saw it in action.
One night in the early hours of the morning I woke to see someone remotely controlling my phone and accessing my email account. They searched and found an email from activists in New York that I was CC'd into requesting to have the famous ABC "tank man" footage from the Tiananmen Square massacre given a UNESCO heritage listing.
The email was left open so I could see it, which I believe was a deliberate attempt to let me know they were watching.
I continued to work as normal. I feel strongly that the moment you adjust your reporting to placate the Chinese authorities, it is the moment you should leave.
Our future was in the hands of Chinese authorities
One way the Chinese authorities try to force foreign journalists to self-censor their work is by threatening not to renew the 12-month residency visas.
I anticipated trouble, so submitted my renewal application six weeks before it was due to expire. If things were okay, you could expect approval in about 10 days. I didn't get a response.
Instead, I was ordered to the Ministry of Foreign Affairs for "a cup of tea", a phrase that every foreign journalist knows is a euphemism for a dressing down.
When I entered the room, my government-appointed minder Mr Ouyong was standing with Ms Sun, an unassuming, bespectacled Chinese bureaucrat. She poured me a cup of tea.
Ms Sun had a pile of my story transcripts sitting in her lap. She drew them out one-by-one, referring to each in turn: "Re-education camps in Xinjiang! Political executions! Imprisoning of labour activists! Experts labelling Xi Jinping a dictator!!!" With each story her anger grew until she was enraged.
The session continued for two hours and it was quite a performance.
Ms Sun claimed I had abused all the people and leadership of China. I countered that I didn't know how that could be possible considering the ABC website had been banned in China.
This infuriated her further and she went on to lay out a more serious charge: I had personally broken Chinese laws and was now under investigation.
As I left the meeting that day, I felt vulnerable. I knew my future, and that of my family, was now in the hands of the Chinese authorities.
I was berated for any 'negative' China coverage
Over the next two weeks I was called in twice more for "cups of tea". The meetings were always angry and always lead by Ms Sun. But the focus had widened.
I was berated for any "negative" China coverage the ABC did on any platform and any program, particularly the Four Corners stories investigating Chinese interference in Australia's democracy.
As the ABC bureau chief, the boss, they believed I should take responsibility for these stories. In their view I was an appointment of the Australian Government and as such could be pressured as a means of passing a message to Canberra.
In a country like China where media is tightly controlled, understanding the concept of independence — the fundamental difference between a state broadcaster and a public broadcaster like the ABC — is not straightforward.
In my last meeting, Ms Sun still would not tell me if my visa renewal was going ahead.
But she did reveal one important detail: the matter was now out of her hands.
A "higher authority was in charge of the investigation", she said, and was outraged by Australia's new interference laws (some of the toughest in the world at that point).
Something was wrong
It was now a week before my visa was due to expire and with it the supporting visas for my wife and three children.
We booked flights back to Sydney for the following Friday night. The plan was to shield the kids from the drama and if worst came to worst, pick them up from school and leave straight for the airport.
We continued life as normally as possible. My wife, Catherine, was incredible under this pressure making calm, rational judgements all the way through the saga.
Early on Monday morning it appeared we had a breakthrough. I was told the visa had been approved and when I arrived at the office Mr Ouyong was waiting.
The atmosphere was tense.
He told me, with a cold anger, I had an extension of only two months (I'd asked for a year) and then added pointedly: "Don't expect to return to the People's Republic of China" and "don't think this mess ends with you".
Relieved the uncertainly and stress appeared to be over, Catherine and I went to the immigration police to have visa extensions stamped into our passports.
The official at the desk began entering our details into the system, but suddenly the mood changed. Something was wrong. We were told to immediately report to Public Security.
It was clear this ordeal was far from over. In fact, there had just been a major escalation.
Then the penny dropped
Once in the hands of Public Security we entered into territory where interrogations and detentions are the norm. As I mulled the possibilities, fear sank into my gut. If this is where our investigation had ended up, then we were in serious trouble.
We were instructed to report to a facility in north Beijing and told to bring my daughter Yasmine, who was 14 at the time, as she was now part of the investigation.
This felt like a line in the sand for me. I could not accept that they would involve my children.
At the same time I was frightened. It felt like part of the Chinese playbook: to go after family members as a way to exact punishment and revenge.
We turned up the next morning at 7:30am and walked into a large security complex. By this stage the Australian Embassy, Department of Foreign Affairs and Trade and my ABC bosses were aware of what was happening and were monitoring my movements.
The complex was newly built but mostly empty, except for the staff sitting dutifully at their workstations. It was so clean you could smell antiseptic. At end of a corridor an official told us to wait.
A short time later I was called into an office where three people were waiting at a desk. A woman, flanked by two older men, was clearly in charge. They did not give their titles or names. The women told me in a tone that came across as arrogant that the investigation was about a visa violation.
Then the penny dropped — this is how I would be expelled from China: a visa violation would avoid a possible escalation with the Australian Government if I was charged with a more serious offence.
I had spent the past three years reporting on dissidents and Communist Party purges where the targets were often convicted of lesser crimes like arson or immoral behaviour.
'You will be put into detention'
The most pressing question was to yet to be answered: Why my daughter?
Then the lead interrogator, the women, replied in slow, strident English: "Your daughter is 14 years old. She is an adult under Chinese law and as the People's Republic of China is a law-abiding country she will be charged with the visa crime".
I replied that as her father I would take responsibility for her "visa crimes". After all, I had put her in this position.
After a pause the women answered: "Do you know that as a law-abiding country we have the right to detain your daughter?".
She knew she had total power over me and she let the words sink in. After some time she added: "I do have to inform you, Mr Carney, that we have a right to keep your daughter in an undisclosed location and I do have to inform you there would be other adults present".
I told her any attempt at this, and I would escalate the situation by involving the Australian Embassy and Australian Government, which was aware of my case.
But if she was trying to terrify me, it was working.
As my final offering, I said to her that we would leave China the next day, no problem.
She laughed in response and said: "Mr Carney, you can't leave the People's Republic of China! You are under investigation and we have put an exit ban on your passport".
Ok, I said. What happens when our visas run out this Saturday? I hoped she might say we would be expelled immediately.
Instead she smiled and said, "Well, you will be put into detention".
Was it all just theatre?
Panic was setting in, but I had to pull myself together and come up with a plan.
In a break I made a pact with Catherine: we would never let Yasmine out of our sight or be moved to separate locations.
After a round of calls to embassy staff, Chinese colleagues and the ABC, we all decided the best approach was to confess guilt and apologise for the "visa crime", with the condition that Yasmine stayed with us. She was mostly unaware of the severity of the situation.
I returned to the woman in the security office and did just that.
One of the men with her, who had a friendly, chubby face, explained the visa violation had come about because I had not transferred the visa that was about to expire from my current passport into a new passport that I had just had issued, within a 10-day timeframe. Instead (as advised) I was applying to have the new visa placed directly into the new passport. Was I guilty? Oh yes, I was! I was just relieved there was no other serious charges.
My best hope was this interrogation was all just theatre, designed to scare and humiliate.
The women then interjected and instructed us to return the next day when my daughter and I would be required to give a taped video confession.
I went in first at 9:00am. The chubby-faced man set up a camera and pushed record and answered question after question about my travel itinerary over the past year.
Finally, it was time to confess my guilt: "Yes, I didn't put visas in my new passport."
My daughter, with my wife beside her, was called in next to give her confession.
By this stage the man with the chubby face was quite friendly. If this was all it was going to be, then it felt like a good sign. But you never knew.
'The investigation is over'
When the lead interrogator returned she told us she would consider our confessions, write a report on our case and send it to "the higher authority" for judgement.
To heighten the tension once again, she said a result could take weeks. Our visas were running out in four days and by now we knew the consequences.
We went home defeated and with no idea what would happen next. But at least we were all still together.
Then suddenly, early the next morning, we got a phone call.
"The investigation is over. The visa extension of two months has been granted. Come immediately back to the security office".
The man with the chubby face was waiting for us.
My daughter and I were asked to sign and thumb print every page of the transcripts from our "confessions", many pages long.
Then with a handshake and a smile he presented us with a certificate stating we were guilty of a visa violation. Our lead interrogator looked on sternly as we left the building, relieved.
A flight out never felt so good
There was one more twist to my story.
A program I made on China's social credit system which uses digital technology to keep control of the population, was getting tens of millions of views around the world.
The Chinese woman I featured in the story as a "model citizen" threatened legal action against me in the civil courts for defamation. Her husband was an active and ambitious Communist Party member. Was this another way to intimidate me and the ABC?
I took advice from an American lawyer based in Beijing who urged me to leave China immediately. As soon as legal proceedings were lodged against me, an exit ban would be activated.
He claimed to be representing dozens of foreigners in a similar position, some who had been stuck for years.
I was counting down the days before we could leave China for good. This wasn't the way I wanted it to end my posting, leaving behind one the world's biggest stories and many good Chinese friends.
But boarding the plane for a night flight back to Sydney with my family on a cold December night had never felt so good.
Matthew Carney is the executive producer of Foreign Correspondent. From 2016-2018 he was the ABC's China bureau chief.