Research the neighborhood you're staying in. It's not uncommon for people to find a hotel that's TL-adjacent, think it's a great location because it's close to Union Square, then find themselves horrified when they step out in the morning.
Best way of researching? Street view / hood maps ?
My knee-jerk answers for where to not stay are downtown, anything near the Tenderloin, anything in the mission close to a Bart station. Bayview/Hunters Point is also on that list, but no one accidentally stays there.