Including code from other themes in child themes

The canonical answer is that themes are for visuals only, the rest go in plugins.

In practice though, people bundle everything in a theme because it’s easier to sell a zip you upload to the themes folder. In the future it will be possible to have themes that contain little to no PHP at all thanks to full site editing.

With that in mind, if you want to take functionality from an unrelated theme, nothing prevents you copying the files over, however, this doesn’t mean that it will work. You’ll almost certainly need to make adjustments so that styling looks right. You may need to implement PHP and JS changes to restore the functionality.

If you can move it to a plugin then that should always be the preferred choice.

If at any point you are tempted to load the code directly from the other themes folder via include or require, do not do this. It is extreme bad practice, and a very bad thing to do. There is no situation where this is a good idea. Avoid at all costs.