Late one afternoon last month, in a meeting room in the offices where I work in north London, I sat and wept. This is not something I make a habit of. My own tears were provoked by the tears of Judy Griffiths, a central interviewee in The Unwanted: The Secret Windrush Files, a documentary we had then just completed.

Judy had come to our offices to watch sections of the programme, to let us know if she was happy with how we’d portrayed her story. Tough, educated and resilient, she is one of a number of victims (or perhaps survivors) of the Windrush scandal that we interviewed for the film.

Even for her, with her level of drive and resourcefulness, taking on a cold, officious and target-driven immigration system was draining and damaging. Yet, in one way, Judy was comparatively fortunate. She happened to have kept hold of some of the documents that the Home Office demanded in order to demonstrate her long residence in the UK. She was also able to track down other scraps of evidence needed to prove something that should never have been in question.

That paper trail, gathered by a woman who has lived and worked in the UK for more than 50 years, included the antenatal records of her now adult children. Others caught in the dragnet of the so-called “hostile environment”, and unable to provide similar documents, were dragged into the lower circles of immigration-law hell.

I cried last month not only because Judy cried, but because I was enormously relieved that our film meant something to her. I don’t know exactly what brought her to tears. My guess would be that seeing herself and her story framed within a TV documentary brought home, in new ways, the staggering injustice of what she has been through, and reminded her of the obvious – that none of it should ever have happened.

But Judy also cried because the film contains an interview with a friend she had recently made and recently lost – Sarah O’Conner, another victim of the scandal. Sarah had moved to Britain aged six and, after 51 years’ residence, had suddenly been refused employment and then benefits. Like Judy she had been forced to become a campaigner for the rights of the so-called Windrush generation. But in September 2018, after a minor operation, she died, aged 57.

Amelia Gentleman reported on the plight of Michael Braithwaite in 2018, highlighting the Windrush scandal. Photograph: Graeme Robertson/The Observer

The Windrush scandal is raw, shocking and ongoing. The damage done is hard to appreciate until you sit down and listen to the testimony of those affected. When the first of Amelia Gentleman’s articles appeared in the Guardian, revealing that British citizens, born in the Caribbean but resident in Britain for many decades, were being denied employment, benefits and healthcare under the hostile environment, a storm of raised voices and hard questions erupted.

David Lammy, visibly angry, gave one of the most impassioned speeches of recent parliamentary history. Even Piers Morgan looked genuinely hot under the collar on breakfast TV when he expressed outrage at the fact that Anthony Bryan – another of the interviewees in The Unwanted – was still waiting for his status to be resolved.

It is testimony to the scale and severity of the Windrush scandal that it was able to command enough media bandwidth and enough headspace within the national consciousness to cut through the background Brexit hubbub. For an outrage to metastasize into full-blown, Defcon-1 national scandal in 2018 it needed to be really, really bad.

During the final, farcical attempts to push her Brexit deal through parliament, Theresa May was said to have worried about her political “legacy”. Her place in history will only become apparent when the Brexit nightmare is, somehow, resolved. There is no question, however, about how May will be remembered by black Britons. Her legacy within that community is set in stone and has little to do with her three dismal years in Downing Street.

May will be remembered as the home secretary who sent vans with “Go Home” blazoned on their sides to patrol our multicultural cities. The politician who, in 2012, declared her intent “to create, here in Britain, a really hostile environment for illegal immigrants”. That soundbite, intended for short-term media consumption, has become May’s epitaph and a chapter heading – alongside “colour bar”, “rivers of blood” and “sus laws” – in a long and troubled history.

In the 18th century, when the ancestors of the Windrush generation were being shipped in chains to the islands of the Caribbean, the doublethink that was an intrinsic feature of the imperial project was briefly exposed. The challenge came when people who had been enslaved under the laws that then governed Britain’s slave colonies were brought to Britain by their “owners”. Some absconded and claimed their freedom. It fell to the judges to determine if those defined as human property in the colonies remained so once they set foot in Britain or, if by breathing in British air, they were freed and magically became legal persons. Ultimately they decided slavery was not legal within Britain.

Jamaican immigrants being welcomed by RAF officials from the Colonial Office after the ex-troopship HMT Empire Windrush landed them at Tilbury. Photograph: PA

Something similar in terms of exposing a doublethink happened after 1948. Then, black and brown people who had been told their whole lives that they were British subjects with the right to come to the “mother country” began to exercise those rights. In 1948, Britain was asked to cash that promissory note. Instead, the charade was exposed because the principle of free movement within the empire, long a hallowed tenet of the imperial project, had in reality only ever been intended to apply to white people.

Postwar Britain, battered and near bankrupt, was desperate to cling on to as much of the empire as possible – rebranding it the British Commonwealth. Politicians, both Labour and Conservative, were united in their determination that Britain should retain her status as a “world power” – albeit a poor relation to the US and USSR in the age of the superpowers.. Key to achieving this, they believed, were the bonds between Britain and the nations of the old Commonwealth – Australia, Canada, New Zealand and South Africa – sometimes tellingly referred to as the “white dominions”.

When, in 1948, parliament passed a new British Nationality Act the aim was to reaffirm existing rights that enabled the two-way flow, between Britain and the old Commonwealth, of people who were regularly described in postwar official documents as “our stock”, “our people” or people of “British stock”. What the politicians failed to predict was that even as they were debating the act, 492 black people from the Caribbean would board the Empire Windrush and exercise their rights as British subjects to work and live in the UK.

The big historical truth that we have yet to confront is wrapped up with the same painful truth that explains how the Windrush scandal of 2018 could have happened – that the arrival of the Empire Windrush in 1948 was unplanned and unexpected. The people on board were unwanted and their moment of arrival set in train two oppositional processes.

It established 1948 as the symbolic beginning of the postwar migration that created modern, multiracial Britain. At the same time it provoked a political struggle that saw successive British governments, both Labour and Conservative, set out to design and introduce laws to limit what they called “coloured migration”.

The deeper roots of the scandal lie not in laws but in beliefs. The belief that Britishness is the same as whiteness David Olusoga

The great dilemma they faced was that any act that put limits on migration of British subjects from all parts of the empire would inevitably limit the movement of white people from the “white dominions”. Whereas draft legislation that overtly targeted the black and brown people would damage Britain’s standing in the world and undermine the creation of the Commonwealth – the rebranded, reimagined version of the empire that included newly independent states, as well as the old dominions. In an interview in 1954, Winston Churchill’s private secretary Sir David Hunt explained the dilemma: “The minute we said we’ve got to keep these black chaps out, the whole Commonwealth lark would have blown up.”

The political struggles of the period that followed the arrival of the Windrush are recorded on the pages of hundreds of documents held at the National Archives. What they reveal is that even before the Windrush set sail from Kingston, British politicians had concluded that “coloured migration” automatically represented a “colour problem” and was thus to be discouraged and curtailed. The other deeper and more fundamental and unquestioned belief that runs through those thousands of archival pages is that black and brown people could never really be British.

The old racism of imperialism not only rendered the postwar political elite unable to see black people as full British citizens, it provided them with a whole glossary of stereotypes and preconceptions that they then deployed in order to justify their aim of introducing immigration controls. In the late 40s and early 50s, a series of studies was launched in Whitehall.

The function of the studies was to find evidence of problems supposedly caused by the presence of black migrants. One study, by the Working Party on Coloured People Seeking Employment in the United Kingdom, reported in late 1953. It concluded, despite much evidence to the contrary, that “coloured workers” struggled to find employment in the UK, and that such difficulties were caused by their “irresponsibility, quarrelsomeness and lack of discipline”. The report also stated that black men were “slow mentally” and in general were “not up to the standards required by British employers”.

British business came to a different conclusion. Several major employers not only hired Caribbean migrants, but actively recruited them directly from the West Indies. By 1956, London Transport was recruiting in Barbados, even loaning migrants the costs of their passage to Britain. British Rail placed ads in the Barbados Labour Office and the NHS appealed to West Indian women to come to Britain and train to become nurses. It was these companies that issued the invitation to the “mother country” that Britain’s postwar governments withheld.

Despite the efforts of five governmental studies there was no evidence that “coloured migration” led to a “colour problem”. Even worse, there was sparse evidence that the public was particularly interested. Minutes from meetings of Churchill’s cabinet from the mid-50s reveal that politicians were well aware “coloured migration” was not an issue about which there was any deep public concern.

Demonstrators protest against the hostile environment immigration policy outside the Home Office in Westminster, London, in April 2018. Photograph: Dominic Lipinski/PA

In a meeting in June 1955, the cabinet debated “proposals for the appointment of an independent committee of enquiry into coloured migration”, noting that “the first purpose of an enquiry should be to ensure that the public ... were made aware of the nature and extent of the problem: until this was more widely appreciated the need for restrictive legislation would not be recognised”. In another meeting, in November 1955, the cabinet concluded that “the problem of colonial immigration has not yet aroused general public anxiety, although there was some concern mainly due to housing difficulties in a few localities where most of the recent immigrants were concentrated”.

It was not until 1962, after the public mood had grown more hostile, that Harold Macmillan’s government finally hit upon a mechanism by which the migration of black and brown people could be limited without curtailing the movement of white citizens of the “old Commonwealth”. The 1962 Commonwealth Immigrants Act used a voucher system based upon employment prospects to determine who was able to enter the UK.

A government working party, set up to explore the options, concluded that this was “the only workable method of controlling immigration from the Commonwealth without either bringing such immigration to a virtual standstill or ostensibly discriminating against immigrants on a basis of colour”. The key word is “ostensibly”.

Another confidential minute noted that while the new system “would apply equally to all parts of the Commonwealth, without distinction on ground of race and colour, in practice it would interfere to the minimum extent with the entry of persons from the ‘old’ Commonwealth”. The then home secretary, Rab Butler, was clear that the act’s “restrictive effect is intended to, and would, in fact, operate on coloured people almost exclusively”.

The 1962 act was the great watershed, the end of the charade. And there are strands of legislative DNA that stretch from that moment, through the Immigration Act of 1971 and the later immigration laws passed under David Cameron, that removed the legal safeguards that shielded the Windrush generation, all the way to the Windrush scandal of 2018.

The deeper historical roots of the scandal, however, lie not in laws but in beliefs. The belief that Britishness is the same as whiteness, and that black and brown people can never truly be British, no matter what the laws say or what is written on their passports. Such beliefs were held, almost universally, by postwar-era politicians.

In the late 20th century, when the multiracial society they were unable to envisage emerged, such notions should have perished. That they did not goes some way to explaining how the scandal of 2018 happened.

David Olusoga is speaking at a preview of The Unwanted: The Secret Windrush Files at the Southbank Centre in London at 7pm next Sunday 23 June and the documentary is on BBC Two at 9pm on 24 June