Thank you for your great answer. However, I did realise that it only works if you created the invoice directly from the sales tab under a customer and you now wish to transfer the invoice to a project.
If you are trying to edit an invoice that was created from a converted estimate to an invoice, then your solution doesn't work completely. On selecting the project at the top left of the invoice, QuickBooks online quickly prompts you that "This will remove any linked transactions."
If you click on OK, you lose all the items you had created on the estimate before you converted it to an invoice.
Here is a screenshot.
So how do we fix this?