For a variety of reasons, unlike most countries, there is no sterile international transit through the United States. To repeat with a footnote, there is no sterile international transit through the United States.* For a foreign traveler, even a Canadian, this is a darn good reason to avoid connecting in the U.S.
*The Transit Without Visa (TWOV) and International-to-International (ITI) programs were suspended in 2003; all passengers connecting from and to international flights must obtain a transit visa or be covered under the Visa Waiver Program (VWP). If your flight is "pre-cleared," say SNN-JFK or YUL-DCA, you will be processed for health, agriculture, customs, and passport/immigration at your departing airport. Your flight into the U.S. in effect becomes a "domestic" one and your transit "domestic" as well. But Costa Rica does not have a pre-clearance treaty with the U.S., so that is besides the point.
In other words, there is no transit lounge in an airport where through passengers can wait to transfer to an outbound flight. Upon landing at your gateway airport, all passengers will disembark directly to a processing facility where they will claim their bags and go through customs and immigration procedures for entry into the United States. An immigration officer cannot just take your word that you are immediately connecting to an outbound international flight, because once you have been stamped in, you are inside the United States, and could simply leave the airport if you wanted to. So if they have cause to deny you admission to the U.S., they will deny you.
As when you are denied entry to any country, the airline that brought you there is required to fly you back to your port of embarkation on the first available flight. I do not know if you would even be allowed to use your onward ticket. So, given the risk of having your trip ruined, it seems a worthy investment to avoid connecting in the U.S. and/or to get some legal advice on removing whatever blocks there are to your admission to the U.S.