It was all going so well for Gabriel Makhlouf. New Zealand's Treasury Secretary began the last week of May getting ready to deliver the government's budget, his last major set-piece before jetting off to become the next governor of the Central Bank in Ireland.
ut by June, Mr Makhlouf was under investigation by New Zealand's public service watchdog, with doubt looming over whether he would see out his last weeks in the job.
It could mark an ignominious end to an otherwise successful stint in New Zealand's public service. Born in Egypt to a Cypriot British father and Greek Armenian mother, Mr Makhlouf moved to New Zealand in 2010 after being headhunted for the role of deputy treasury secretary.
Gabs, as he is affectionately known around Wellington, had enjoyed a successful career in the British civil service. He worked at the British Treasury and the OECD, where he worked on taxation, including money laundering and tax havens. He also served as Chancellor Gordon Brown's principal private secretary.
Mr Makhlouf presided over an innovative treasury in New Zealand. His last years in the role have seen him undertake sweeping reforms of the Reserve Bank, which will shift to a committee-based rate-setting model, much like the one he will preside over in Europe. He's also shepherded in a dual mandate for the bank, which now targets maximum sustainable employment as well as low inflation.
His chief legacy will be pushing the treasury to broaden its focus from traditional economic measurements of progress to a more holistic, wellbeing approach. The department began working on measurements of living standards and the quality of the environment, and fed that information back into analysis of government policy. The work was innovative, implementing in a practical way work done by the OECD on moving beyond measurements like GDP as the sole barometer of economic success.
But Mr Makhlouf's broad interpretation of his role brushed up against the former right-leaning government, which opted out of using treasury wellbeing work in its budgets. There were also growing fears the new, broader focus had led to a decline in the quality of its economic advice, one of the ministry's primary roles.
Some in Wellington began to lose confidence in treasury advice, which had once been touted as the best in the civil service. A biennial survey measuring satisfaction among people who used treasury economic advice and fiscal projections showed it falling from 70pc in 2015 to just 47pc in 2017. But, hewing close to the wellbeing mantra, Mr Makhlouf's treasury didn't appear overly concerned.
It started to hire fewer economists in policy roles. In 2017, a minority of analysis staff held any economics qualification. The ministry also didn't appear to be in a great hurry to remedy things.
That year just four of the 24 new hires in analysis roles had training in economics.
Last week's budget should have been Mr Makhlouf's crowning achievement before leaving on June 23. Dubbed the Wellbeing Budget, it marked the first time spending bids had been made using a raft of indicators based on wellbeing, rather traditional measurements of growth.
The left-leaning coalition led by Prime Minister Jacinda Ardern was far more enthusiastic and used the budget to tout its left-wing credentials everywhere from New York to Davos.
But success was not to be. The National Party, New Zealand's main opposition, was able to release more than 20 pages of highly confidential information from the government's budget two days before its scheduled delivery.
Mr Makhlouf responded quickly, saying the treasury had been "deliberately and systematically" hacked more than 2,000 times.
The reality was more prosaic. A opposition staffer had simply used the search bar on the department's website to reveal budget details that were partially visible despite being on a supposedly hidden part of the site. But by the time the truth was revealed, Mr Makhlouf had already called in the police and dragged in New Zealand's National Cyber Security Centre, triggering nationwide outrage that the main opposition party might have implicated itself in nefarious hacking.
Finance Minister Grant Robertson jumped into the fray, calling on the National Party to stop releasing hacked material.
In an embarrassing 5am press release on budget morning, the treasury was forced to dial back its initial claims and acknowledge the so-called hack was not illegal.
Mr Robertson also began to distance himself from the catastrophe, expressing his disappointment with the treasury. Finally, the State Services Commission (SSC), the civil service watchdog, announced it would be investigating Mr Makhlouf's actions.
Mr Makhlouf had been well-liked and respected in the small set of senior Wellington mandarins. His international experience had made him stand out in a predominantly New Zealand-born cohort.
The fact that a professional of Mr Makhlouf's calibre let the embarrassing but non-threatening hack spiral so rapidly out of control has many in Wellington scratching their heads - it seems uncharacteristic behaviour from the usually sober Gabs.
His last weeks in the role may have revealed a strand of politicisation and attachment that is frowned on in the civil service. Should the SSC find Mr Makhlouf acted inappropriately, it would make an ignominious end to a mostly successful stint in one of New Zealand's most senior public service roles.
Thomas Coughlan is a political reporter at Newsroom NZ, based in Wellington, New Zealand