The error is a result of the equal sign. The correct syntax is the following, which will restrict to a relationship the that property value.
[:HAS_INVOICE{invoiceState: ‘Paid’}]
you can find the longest path by sorting on the path length and returning the longest. Add the following after your ‘RETURN p’ statement:
ORDER BY length(p) DESC
LIMIT 1
the above solution assumes there is only one longest path, or you just one of the longest at random if there are more than one. I can provide a different solution when there could be multiple, but it seems that should not occur in your case.