More general enforcement of available parent folders when selecting folder type, in JS