In general, I think a company should always consider giving code to the FOSS community, whenever they use FOSS libraries themselves. Let's say they use Node.JS and on top of that add MIT-licensed packages from NPM, then they should make sure to also return code.
One way to contribute code back is by sending fixes, improvements and added features upstream. Another way to contribute is by separating general-purpose parts of the secret code base and packaging them into a separate module, which they release under a permissive license (MIT, BSD, Apache, MPL,...). It should, of course, be something which is still missing from the ecosystem, or something for which there are only abandoned libraries available.
A company should push such software into the open, in order to get the added benefit of