A man inadvertently foiled an attempted bank robbery after assuming it was an April Fool prank, a court has heard.