Moral rights have almost (or until I think about it a lot harder, absolutely) nothing to do with this. I have refused to sign contracts which ask me to waive my moral rights because if, for example, Donald Trump wanted to use one of my songs as his campaign music, I would want to be able to say, "No, that goes against my moral rights and I don't want to be associated with you in that way". So I understand moral rights and what they're worth.
Who the author is is simply what is agreed. There is no "truth detector" in the Performing Right Society (PRS) unless a claim of authorship is contested. If Paul McCartney wants to say that John Lennon helped him to write "Yesterday", he has the right to say that it is a "Lennon and McCartney" song. It doesn't matter whether he is telling the truth or if Paul wrote the song completely on his own. The "fact" is that the song was filed with the PRS as a Lennon and McCartney composition and that becomes the fact. The fact and the truth do not have to be the same thing. In law, Authorship can be assigned to whomsoever agrees that it can be assigned to if it is not contested.
In law (which is an ass) if a person is convicted of murder then they are in law guilty of murder. The 'fact' that they may or may not be innocent is simply irrelevant in the eyes of the law with respect to the conviction. A person convicted of murder is by definition a murderer - even if they have never killed anyone or been the cause of another person's death. If it can be proven at a later date that the conviction should be quashed, then the person, by law, could be no longer a murderer. The truth and facts and lies and contracts and authorship are not arrived at by some panoptic reality that knows who had the idea or who put it on to paper or film or digital media. It is arrived at by what is submitted/published and by who agrees to be the uncontested author(s), which might be my best mate if I've written something and I'm feeling generous.