This textbook doesn't expound how to determine whether a mistake is fundamental enough. Assume that A and D mightn't have contracted.
Under section 5(4) of the Theft Act 1968:
Where a person gets property by another’s mistake, and is under an obligation to make restoration (in whole or in part) of the property or its proceeds or of the value thereof, then to the extent of that obligation the property or its proceeds shall be regarded (as against him) as belonging to the person entitled to restoration, and an intention not to make restoration shall be regarded accordingly as an intention to deprive that person of the property or proceeds.
This subsection deals with the situation where the defendant has received property as a result of another’s mistake and is under an obligation to restore the proceeds or their value. A good example of where section 5(4) operates is Attorney-General’s Reference (No. 1 of 1983),39 where a police officer was overpaid her salary by the police force. She was under an obligation to return the money (once she was aware of the overpayment) and therefore the money could be treated as belonging to another (the police force).
Where A hands to D property on the basis of a mistake, four situations need to be distinguished:
(1) The mistake is so fundamental that ownership does not pass. So although D possesses the property, in fact it is still owned by A. There is therefore no difficulty in establishing the ‘property belonging to another’ requirement if D is charged with theft.
(2) The mistake is not so fundamental that ownership does not pass and so D owns the property. But the mistake is sufficient to mean that D is under an obligation to return the money or its proceeds. This means that, relying on section 5(4), the property belongs to A for the purposes of the law of theft and so D can be convicted.
(3) The mistake is one that means that D holds the property on trust for A. In such a case A has an equitable interest in the property and the property belongs to A under section 5(1) of the Theft Act, so D can be convicted of theft (see e.g. Shadrokh-Cigari  Crim LR 465 (CA); Hallam and Blackburn  Crim LR 323 (CA)).
(4) The mistake is not significant enough to give rise either to a claim that ownership did not pass, or to a claim that there is a legal obligation to make restoration. In that case the property will belong to D and no theft charge can lie, unless the transfer from A itself can be regarded as dishonest. In that case, after Hinks  3 WLR 1590 (HL), a charge of theft could be brought.
Herring, Criminal Law: Text, Cases, and Materials (2020 9 ed). p 525.