I was finally able to figure it out thanks to Michael Schumacher's comment. I put the steps here since I couldn't find these steps laid out clearly anywhere else. The thing that confused me the most was that I didn't know that the "floating selection" layer could be "anchored" onto the mask.
This solution keeps the smoothness of the text, and doesn't use the "select" tool.
Step 1: Copy the text layer. (Select it as shown, then Command + c on a Mac computer.)

Step 2: Select the mask. *Warning! This is NOT selecting the mask, but the original layer. The white border means it is selected.

Therefore, in this image, the mask is selected because it has the white border. Select the mask by clicking directly on the mask's preview-image box. (It's kind of hard to see it being selected here, because the whole mask is also white, and so is the border.)

Step 3: While the mask is selected, click Paste. (Paste is Command + V on a Mac computer.) It should look like a new layer called "Floating Selection."

Step 4: While the floating selection is still selected, click on the Anchor icon. It is in the bottom-right corner of the screenshot below.

This is the result of clicking the anchor icon:

Step 5: Fill the shape.
Select the shape layer (not the mask):

When you fill it in, it will still fill in the whole shape (as you can see in the preview, next to the mask, in the layers window), but the mask will be applied as long as it is "enabled."

After this, you can export to PNG and the mask will still be applied. Or you can continue to the next step, if you want to continue modifying the image.
Step 6: Combine the mask to the actual layer, if you want to be able to work with it that way.
Right click the mask, and click "Apply Layer Mask":

Then this is the result:
