If I fly from the US to Dominican Republic but I have a layover in Panama City, Panama, do I have to go through customs or just stay in the terminal and then board the flight to Dominican Republic? I figured I'd have to go through customs in both countries, but I really don't want to.
We flew Copa Air from SFO > PTY > ASU in September, with an eight-hour layover in PTY. Our luggage was checked through, and we wanted to leave the airport to take a local tour during the layover. We went through Immigration and Customs to leave airside, and then went through them again (and security, too) when arriving back at PTY for the departing flight. The process was wholly without drama in both directions — these are long layovers, and I suspect the authorities are used to this behavior.
OTOH, if you're just going to hang around airside during the layover, you won't need to go through Immigration and Customs.
And note that my answer does not address whether a particular traveler needs a visa to enter Panama. I'm a US citizen, and didn't. YMMV.
Since you're inquiring about customs & not boarder control (aka immigration) Panama customs is generally a breeze. Should you go through, they are basically looking for import of goods worth more than $500. Generally, you'll see many Chinese at a table on the right-hand side where their copious bags of products they will be selling in their stores. The Chinese are a very large minority in Panama. So much so the corner stores are called 'chinitos' regardless of the nationality of the owner.
I've brought in 50 pound bags of hydroponic clay pebbles on several trips and have had different experiences each time: items reviewed by agricultural agents twice, the taxing authority mentioned above, or waved through. I came through with a brand new chain saw once and they asked if it cost more than $500 and I said no. It was the most expensive thing in my bag, and clearly new. The rest of the contents they didn't bother with, or inquire as to total market value of what I carried.