It depends on the quality of your shoe and the nature of your hike. For example, if you’re wearing a pair of well-fitted, broken-in Chaco sandals (which, crucially, offer exceptional grip and tread and have awesome arch support), you should be fine hiking long distances. In terms of the hike itself, if you’re doing a forest hike with frequent stream crossings, sandals can be great; for rocky, high-alpine hikes, not so much. If you’re at all prone to ankle twists, you should never wear sandals when doing long-distance hikes. More important than distance is weight consideration. The more weight you're carrying, the more ankle support you'll need. While you can backpack in hiking sandals, boots will better support the ankles.