When an ideal gas expands at constant pressure, it undergoes an isobaric process. During this process, heat flows into the gas from the surroundings. This is because the gas is doing work on its surroundings by expanding, and in order to maintain constant pressure, heat must be added to the gas to compensate for the energy lost as work. Therefore, heat flows into the gas.