Yes, Ryan Loche should have been in taxi so late at night in Rio de Janeiro, even if it may be dangerous. Loche was celebrating his Olympic victories with other athletes. It is important that the Olympic athletes be able to be perceived as human - they are idealized for their abilities, but held to an unfair standard if they are judged for staying out late in Rio, even if it is dangerous.
Rio has had plenty of time to prepare for and plan for the Olympics. The city is known for high crime and organizers should have addressed security concerns that may potentially arise. Ryan Loche was not breaking any laws and was taking a taxi back to his hotel. He had no reason to think his safety was in jeopardy.
Loche was the victim of a crime because his taxi was attacked by criminals, however, he was perfectly within his rights to be in a taxi that late at night. He is an adult and can make whatever choices he wants to make. A more pertinent question is why isn't law enforcement in Rio making sure that the athletes are safe at any time of day or night.
There have been so many reports of crime and violence in Brazil, and with some of the athletes being robbed upon arrival, it doesn't make sense that those swimmers would risk going away from the Olympic village. Taking a taxi isn't necessarily a risky behavior, but the athletes have to consider the overall surroundings and their security.