The if statement should only execute if the replacement was successful.
The unpatched if condition is not robust to additions of new states of AddProofStatus.
This patch makes the condition more explicit which is easier to read and more robust to
future changes.