Install the hardwood flooring up to the planks that meet the expansion.
Measure the planks and mark the backs of them where you will need to make cuts. You may need to cut corners out of the planks, cut them to length or rip-saw them for a proper fit. While measuring, account for the 1 1/8-inch gap you'll need for transitioning to brick hearths and 1-inch gap for lower- or same-height transitions. Measure twice, cut once.
Dry-fit the planks in place to make sure you have measured and cut correctly.
Install the planks around the expansion.
Lay the molding track in the gap and determine the correct placement by dry-fitting the molding on the track in the gap. Install the molding track within the gap with construction adhesive. The track holds the molding. In some cases, the molding will not have a track and you will secure it directly to the subfloor.
Install the molding with construction adhesive and the proper fasteners. For example, if you are securing to a concrete floor, you must use concrete nails and a concrete adhesive. For wood subfloors, use screws and an adhesive made for wood. Typical construction adhesive is ideal.
Measure the thickness of the planks and make small pencil marks around the hearth just above this height. The marks should be just high enough for the boards to slide under but not high enough to leave a visible gap between the hearth and the floor.
Undercut the brick at the marks with a jamb saw and a diamond-tipped blade. Only undercut far enough for the planks to fit underneath and still have the required expansion gap.
Install the hardwood floor up to and just under the brick where you have undercut. This gives you a clean finish without the need for a transition molding around your brick hearth.