Trapping of drops due to wettability contrast in porous materials emerges in a variety of subsurface and manufacturing applications. In carbon capture and storage, carbon dioxide must be trapped in order to avoid its release into the atmosphere, while trapped oil must be displaced. Both carbon dioxide and oil can exist as drops in porous media. The migration of a single drop attached to a wall can be hindered if the wall surface has a different wettability. However, the trapping condition becomes more complicated in the presence of two or more drops. In this work, we aim to study the trapping mechanism during thermocapillary migration of a merging drop on a heterogeneous surface. To do so, numerical simulations have been performed using the Front-Tracking/Finite Volume Method, where the Navier-Stokes equations are coupled with the conservation equations. The generalized Navier boundary condition (GNBC) has been used as the slip model to remove the viscous singularity. The combined finite-volume and tracking method is able to deal with different types of discontinuities in compressible or incompressible fluid flows, as e.g., interfaces. The material properties of the drop and the ambient fluid are different, and surface tension depends on the temperature. The results have shown that there exist three regimes characterizing the motion of merging drops, including the passage of the leading drop, the trapping of the merging drop, and the partial trapping, which correspond to the trapping of the leading drop but the passage of the merging drop. We show that there is a critical wettability contrast at which the merging drop gets trapped. The effects of Marangoni number (Ma) and viscosity ratio are investigated. The critical wettability contrast decreases with the increase of Ma number and the regime shift as a function of the viscosity and Marangoni number. These findings have implications for the design of geological carbon dioxide storage, improvement of oil recovery and microfluidic device development.