You shouldn't have much problem getting through immigration at GRU as the BA flight is often the first in, and I think there are four TAM flights to GIG within four hours of the BA flight arriving. If you play it safe and book on a later flight you might be able to move onto an earlier flight.
I'd advocate caution here. GRU immigration has been complete bedlam on my last few visits as there are now several more early arrivals. Ground staff told me that the wait is regularly 2 hours or more with queues running up the international pier.