For example, I pay a cup of coffee with bitcoin, and later remove that transaction from the pending block that is not yet on chain. After 10 mins, I successfully and luckily solve the PoW problem, and broadcast the modified block to everyone as well as append it to the blockchain.
Is the scenario above possible? If it is, how is it prevented?