I return transaction promise which should wait for transaction to finish before stopping the function. The transaction executes fine, but the promise seems to never resolve.
There was a known issue with older versions of the firebase-admin SDK where Firebase Database references and snapshots couldn't be JSON serialized and thus couldn't be used in return values for Cloud Functions. This includes transaction return values since they also have snapshots.
Your hack works around the bug; you should also get the fix if you update your version of firebase-admin.