Urban scaling theory explains the increasing returns to scale of urban wealth indicators by the per capita increase of human interactions within cities. This explanation implicitly assumes urban areas as isolated entities and ignores their interactions. Here we investigate the effects of commuting networks on the gross domestic product (GDP) of urban areas in the US and Brazil. We describe the urban GDP as the output of a production process where population, incoming commuters, and interactions between these quantities are the input variables. This approach significantly refines the description of urban GDP and shows that incoming commuters contribute to wealth creation in urban areas. Our research indicates that changes in urban GDP related to proportionate changes in population and incoming commuters depend on the initial values of these quantities, such that increasing returns to scale are only possible when the product between population and incoming commuters exceeds a well-defined threshold.