Illegal? I wouldn't use that term. From an insurance perspective, the flight wouldn't be insured but from a regulatory perspective, the pilot is permitted to fly that aeroplane.
I would say the PIC/PH is entitled to log it, but the other pilot is not.
Happy to stand corrected.