Consider an ideal gas in a cubical container as our system (only the gas is the system, not the walls of the container). If I understand correctly, if the gas expands at constant pressure $P_{int}$ greater than the ambient pressure $P_{ext}$ (after heating the gas to a certain temperature, the walls of the container, which we'll assume undergoes plastic deformation, can no longer provide a pressure whose sum with the atmospheric pressure counteracts the pressure of the gas, and the gas starts expanding such that as the volume gets scaled by some factor, the temperature gets scaled by that same factor, allowing for expansion at constant pressure $P_{int} > P_{ext}$), the work done by the gas should be
$$ W = \int{\textbf{F}}d\textbf{s} = \int{\frac{\textbf{F}}{A} Ad\textbf{s}} = \int{\textbf{P}_{int}dV} = \textbf{P}_{int} \int{dV} = \textbf{P}_{int}\Delta V . $$
But this Khan Academy article says that the work done by the expanding (or shrinking) gas is
$$ W = \textbf{P}_{ext}\Delta V, $$
and, now that I think about it, shouldn't the net work be the difference in works done by the system (gas) and the surroundings, making the correct expression
$$ W = \int{(\textbf{P}_{int} - \textbf{P}_{ext})}dV = (\textbf{P}_{int} - \textbf{P}_{ext}) \Delta V ? $$
Also, assuming the first expression is true, does this mean that, for an ideal gas, $\textbf{P}V (=NkT=nRT=\textbf{P}\Delta V$ where $V_i=0)$ is the work required to "make room" for the gas (enthalpy minus internal energy) only if the greater interior pressure was a constant function of volume and temperature during the expansion from zero volume, and this is what makes work path-dependent and not a state function? (If the interior pressure was a non-constant function of volume dring the expansion from zero volume, work would be given by a line integral, correct?)