If a rule exists at both global and project level, which one applies?

In general, rules set at the project level take precedence. If a project rule has a corresponding rule in the Settings screen, any change to that rule in Settings does not affect existing projects; it only applies to new projects, which inherit the rule from the global Settings level by default. And afterwards, the project-level rule takes precedence.

The project rules Hide non-billable time entries on invoices and Hide non-billable expense entries on invoices are a known exception to this. Check out this article for more details: Global and project-level rules.