The regulator rewrote a draft report which had contradicted MI5’s false evidence, the BBC can reveal.