What determines when a nation has an unfavorable balance of trade?
The most basic answer to this is that the comparison between a country's exports and its imports is what determines when it has an unfavorable balance of trade. When a country imports more than it exports, its balance of trade is negative and most people would say that is unfavorable.
If you are asking why a country might import more than it exports, that is a much more complicated question. One reason for this could be that the country has deliberately weakened its currency so that the country's exports will be cheap and imports will be expensive. China is accused of doing this.
A second major factor is the relative wealth of the two countries (a rich country is likely to import more from a poor country than vice versa.) This, too, plays into the US-China balance of trade.