Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'underscore';
import {format} from 'date-fns';
import {format, parseISO} from 'date-fns';
import Str from 'expensify-common/lib/str';
import lodashGet from 'lodash/get';
import lodashIntersection from 'lodash/intersection';
Expand Down Expand Up @@ -1344,7 +1344,7 @@ function getModifiedExpenseMessage(reportAction) {
const hasModifiedCreated = _.has(reportActionOriginalMessage, 'oldCreated') && _.has(reportActionOriginalMessage, 'created');
if (hasModifiedCreated) {
// Take only the YYYY-MM-DD value as the original date includes timestamp
let formattedOldCreated = new Date(reportActionOriginalMessage.oldCreated);
let formattedOldCreated = parseISO(reportActionOriginalMessage.oldCreated);
formattedOldCreated = format(formattedOldCreated, CONST.DATE.FNS_FORMAT_STRING);
return `changed the request date to ${reportActionOriginalMessage.created} (previously ${formattedOldCreated})`;
}
Expand Down
8 changes: 5 additions & 3 deletions src/libs/TransactionUtils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Onyx from 'react-native-onyx';
import {format} from 'date-fns';
import {format, parseISO, isValid} from 'date-fns';
import lodashGet from 'lodash/get';
import _ from 'underscore';
import CONST from '../CONST';
Expand Down Expand Up @@ -175,9 +175,11 @@ function getCurrency(transaction) {
*/
function getCreated(transaction) {
const created = lodashGet(transaction, 'modifiedCreated', '') || lodashGet(transaction, 'created', '');
if (created) {
return format(new Date(created), CONST.DATE.FNS_FORMAT_STRING);
const createdDate = parseISO(created);
if (isValid(createdDate)) {
return format(createdDate, CONST.DATE.FNS_FORMAT_STRING);
}

return '';
}

Expand Down