There's a setting for it. In the table properties go to the layout tab, and where there is a section marked "use borders" there is button that will allow you to change the colour. If you click on the button it goes into more detail and there is the option to create an expression that dictates the colour.
I guess you could use an if statement to set it to a colour based on a condition, and either nothing or to match the background colour if not.
If you are unable to view the option to edit borders, it may be that you have simplified styling mode set. To change this, go to the document properties dialogue in the settings menu, then click on the "general" tab. There will be an option to change the styling mode. Change it to advanced if this is the case.