Heat transfer near geothermal heat exchangers in the presence of groundwater flow has been extensively studied over the past years. However, previous studies often overlooked the presence of an unsaturated layer in the shallow subsurface soil, or disregarded phase change and fluid flow within this layer. In this study, a comprehensive hydro-thermal model is developed to evaluate heat transfer near a partially submerged geothermal borehole in groundwater flow while incorporating phase change and liquid and vapor flow in the unsaturated layer. The effect of unsaturated soil hydraulic analysis on heat transfer and energy efficiency of the geothermal piles is explored under varying soil permeabilities, air-entry suctions, solid thermal conductivities, and soil types. Consideration of water content variation and unsaturated fluid flow in the model enhances heat injection rate by up to 11.23 % in highly permeable soils. However, in scenarios with higher solid thermal conductivity, or lower air-entry suction values, the heat injection rate reduces by as much as 16.13 % due to unsaturated soil hydraulic analysis. Furthermore, it is found that consideration of unsaturated soil hydraulic analysis is of greater importance in Bonny silt than sandy soil, lowering the heat injection rate by 8.53 % and 2.53 %, respectively.