To the legal search example, suppose the police frequently stop by your house to discuss neighborhood gremlins. If they happened to accidentally see the boxes of evidence you'd be in trouble. You're allowed to destroy them though, and you might have a habit of destroying evidence for each of these gremlin chats. Doing so is legal.
Later, the police show up with a warrant (your example). If you think you're doing your normal gremlin evidence destroying and not blocking that warrant, destroying that evidence is still legal even with the police waiting on your porch to legally, forcibly search your house. The _intent_ behind your actions, at least in this case, is a core component of the crime.
Mind you, nobody will believe you, so you'll still have a hard time in court proving it (this is mildly in your favour because it's actually the prosecution's duty to prove your intent rather than your duty to prove lack of intent, but they're not exactly going to have a hard time convincing a jury that when you destroyed a bunch of evidence with police on your porch with a warrant it was because of that warrant), but it's still legal.