But when their search doesn’t return any results, I don’t want the sidebar to show up
So if they don’t get any results, you’re going to leave them stranded without the normal navigation links? Not very user-friendly…
However, if that’s what you want to do, it will depend upon where sidebar.php is called in your theme. Before or after search.php?