Your book isn't doing a very good job of explaining this. It has led you think in terms of which temperature is higher in a particular problem and which temperature is lower. This is not the proper way of analyzing this. You need to focus rather on which temperature is situated at lower x, and which temperature is situated at higher x. This is because the heat flux is really a vector quantity. In reality, it should be accompanied by a unit vector in the x direction. If the ambient temperature is at lower x and the wall is at higher x (like say adjacent to the wall at x = 0), then the heat flux vector is $$\mathbf{q}=h(T_{ambient}-T_{wall})\mathbf{i_x}\tag{1}$$It doesn't matter which temperature is higher and which temperature is lower. The temperature at smaller x comes first and the temperature at higher x comes last. Similarly, at the boundary x = L, the wall temperature is situated at lower x than then ambient. Therefore, at that boundary, $$\mathbf{q}=h(T_{wall}-T_{ambient})\mathbf{i_x}\tag{2}$$It doesn't matter which temperature is higher and which temperature is lower.
In Eqn. 1, if the wall temperature is higher than the ambient temperature, all that means is the the heat flux is in the negative x direction (rather than the positive x direction).